HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
mixin tenlist()
.numlist
each f in [0,9,8,7,6,5,4,3,2,1,0]
.num=f
mixin sixlist()
.numlist
each f in [0,5,4,3,2,1,0]
.num=f
.timer-wrap
.timer
.countdown.fc
.callout
.now Now
.price
div $39
span 99
.sub Original price $59
span 99
.timeout
h1 Time up
h2 Time is running out
a.view(href='')
span View Deal >>
.numbers.fr
.mins.tens
+tenlist
.mins.ones
+tenlist
.seperator :
.secs.tens
+sixlist
.secs.ones
+tenlist
timeout = 1880s
minsSize = 8rem
secsSize = 6rem
pretimeout = timeout - 1s
minstens = (6000s - timeout + 599s) * -1
tmod = timeout % 600
minsones = (600s - tmod + 59s) * -1
secstens = (60s - (tmod % 60) + 9s) * -1
secsones = (10s - (tmod % 10)) * -1
body, html
margin 0
height 100%
body
display flex
justify-content center
align-items center
font-family 'Helvetica Neue', Helvetica, Arial, sans-serif
margin 0
font-size 14px
background #f4f4f4
a
text-decoration none
.fr
display flex
.fc
display flex
flex-direction column
.timer-wrap
background url(http://img11.deviantart.net/ceef/i/2014/070/2/c/pastel_space_background___wallpaper___3_by_goldcat742-d71vlqr.jpg)
background-size cover
border 1.4rem solid white
padding 2rem
color white
width 486px
box-sizing border-box
margin 0 auto 1rem auto
.timer
padding 1rem
position relative
background #031722
box-shadow 0 0 1rem black
h2
margin 0
font-weight 600
font-size 1rem
color #C20D78
animation fadeout 2s pretimeout linear forwards
.view
margin .5rem 0 1rem 0
color inherit
animation fadeout 2s pretimeout linear forwards
span
background #C20D78
padding 0.3rem 1rem
.numbers
align-items flex-end
font-size 12px
animation fadeout 2s pretimeout linear forwards
.mins
font-size minsSize
line-height minsSize
height minsSize
overflow hidden
&.ones .numlist
animation minones-jaggy 600s cubic-bezier(0.990, 0.025, 0.970, -0.120) infinite
animation-delay minsones
&.tens .numlist
animation mintens-jaggy 6000s cubic-bezier(1, 0.001, 1, 0.001) forwards
animation-delay minstens
.secs
font-size secsSize
line-height secsSize
height secsSize
overflow hidden
&.ones .numlist
animation secones-jaggy 10s ease-in infinite
animation-delay secsones
&.tens .numlist
animation sectens-jaggy 60s cubic-bezier(0.990, 0.025, 0.970, -0.120) infinite
animation-delay secstens
.mins, .secs
background linear-gradient(top, #0C1A23,#152836,#0C1A23)
box-shadow inset 0 0 3px rgba(255,255,255,0.2)
margin-right 0.5rem
.seperator
font-size 3rem
line-height 6rem
margin-right 0.5rem
.callout
position absolute
top -1.6rem
right -1.6rem
background #C20D78
text-align center
border-radius 50%
height 10rem
width 10rem
display flex
flex-direction column
justify-content center
z-index 10
font-size 1rem
animation moveCallout 1s pretimeout forwards
.price
font-size 3.6em
display flex
justify-content center
align-content flex-start
span
font-size .6em
line-height 1.4
.sub
font-size .8em
span
font-size .6rem
line-height 1.4
.now, .price, .sub
animation shrinkFade 1s pretimeout forwards
.timeout
opacity 0
height 0
animation growFade .5s pretimeout forwards
@keyframes secones-jaggy
for i in 0..10
{10% * i}
transform translateY(-6rem * i)
{(10% * i) + 8}
transform translateY(-6rem * i)
@keyframes sectens-jaggy
for i in 0..6
{100% / 6 * i}
transform translateY(-6rem * i)
{(100% / 6 * i) + 9.99}
transform translateY(-6rem * i)
@keyframes minones-jaggy
for i in 0..10
{10% * i}
transform translateY(-8rem * i)
{(10% * i) + 9}
transform translateY(-8rem * i)
@keyframes mintens-jaggy
for i in 0..10
{100% / 10 * i}
transform translateY(-8rem * i)
{(100% / 10 * i) + 9.5}
transform translateY(-8rem * i)
@keyframes fadeout
0%
opacity 1
100%
opacity 0
@keyframes shrinkFade
100%
height 0
margin 0
opacity 0
@keyframes growFade
100%
height auto
opacity 1
@keyframes moveCallout
100%
top 50%
left 50%
transform translate(-50%, -50%)
Also see: Tab Triggers