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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
- 'use strict'
- const logs = 7
- const streaks = 10
- const sticks = 4
- const sparks = 8
- const flames = 7
.stage
.campfire
.sparks
each spark in Array(sparks)
.spark
.logs
each log in Array(logs)
.log
each streak in Array(streaks)
.streak
.sticks
each stick in Array(sticks)
.stick
.fire
.fire__red
each flame in Array(flames)
.flame
.fire__orange
each flame in Array(flames)
.flame
.fire__yellow
each flame in Array(flames - 2)
.flame
.fire__white
each flame in Array(flames)
.flame
// colors
$page-background = radial-gradient(#550d39, #270537)
$wood = #781e20
$light-wood = #b35050
$red-flame = saturate(#ce1e04, 20%)
$orange-flame = saturate(#fd980f, 20%)
$yellow-flame = saturate(#fde37b, 20%)
$white-flame = saturate(#fef1d9, 0)
// measurements
$scale = 1
$fire-duration = 2s
$campfire-size = 600px
$rings = 7
$log-ring-small = 2.5px * $scale
$log-ring-large = 8px * $scale
$streak-rows = 5
$streak-gap = 10px * $scale
$streak-height = 2px * $scale
$streak-border-radius = 20px * $scale
$log-width = 238px * $scale
$log-height = ($streak-gap * ($streak-rows + 1)) + ($streak-height * $streak-rows)
$log-border-radius = 32px * $scale
$stick-width = 68px * $scale
$stick-height = 20px * $scale
$stick-border-radius = 10px * $scale
$flame-width = 48px * $scale
$flame-offset = 138px * $scale
$small-flame-width = 32px * $scale
$spark-width = 6px * $scale
$spark-height = 20px * $scale
$spark-border-radius = 18px * $scale
// functions
grayscale(n)
if (n >= 0)
rgba(255, 255, 255, n / 100)
else
rgba(0, 0, 0, n / 100)
html
body
width 100%
height 100%
margin 0
padding 0
background $page-background
.stage
width 100%
height 100%
display flex
align-items center
justify-content center
.campfire
position relative
width $campfire-size
height @width
transform-origin center center
transform scale(0.75)
.log
position absolute
width $log-width
height $log-height
border-radius $log-border-radius
background $wood
overflow hidden
// create new z-stacking context
opacity 0.99
&:before
content ''
display block
position absolute
top 50%
left ($log-height / 2)
width $log-ring-large
height @width
border-radius $log-border-radius
background $light-wood
transform translate(-50%, -50%)
z-index 3
box-shadow 0 0 0 $log-ring-small $wood,
0 0 0 ($log-ring-small + $log-ring-large) $light-wood,
0 0 0 ($log-ring-small * 2 + $log-ring-large) $wood,
0 0 0 ($log-ring-small * 2 + $log-ring-large * 2) $light-wood,
0 0 0 ($log-ring-small * 3 + $log-ring-large * 2) $wood,
0 0 0 ($log-ring-small * 3 + $log-ring-large * 3) $light-wood
.streak
position absolute
height $streak-height
border-radius $streak-border-radius
background $light-wood
// top row
&:nth-child(1)
top $streak-gap
width 90px
&:nth-child(2)
top $streak-gap
left (90px + $streak-gap)
width 80px
&:nth-child(3)
top $streak-gap
left (90px + 80px + $streak-gap * 2)
width 30px
// second row
&:nth-child(4)
top ($streak-gap * 2 + $streak-height)
width 132px
&:nth-child(5)
top ($streak-gap * 2 + $streak-height)
left (132px + $streak-gap)
width 48px
&:nth-child(6)
top ($streak-gap * 2 + $streak-height)
left (132px + 48px + $streak-gap * 2)
width 28px
// third row
&:nth-child(7)
top ($streak-gap * 3 + $streak-height * 2)
left ($log-height + 4px)
width 160px
// fourth row
&:nth-child(8)
top ($streak-gap * 4 + $streak-height * 3)
left 110px
width 40px
&:nth-child(9)
top ($streak-gap * 4 + $streak-height * 3)
left (110px + 40px + $streak-gap * 2)
width 54px
// fifth row
&:nth-child(10)
top ($streak-gap * 5 + $streak-height * 4)
left 90px
width 110px
.log
transform-origin center center
box-shadow 0 0 2px 1px rgba(0, 0, 0, 0.15)
&:nth-child(1)
bottom 100px
left 100px
transform rotate(150deg) scaleX(0.75)
z-index 20
&:nth-child(2)
bottom 120px
left 140px
transform rotate(110deg) scaleX(0.75)
z-index 10
&:nth-child(3)
bottom 98px
left 68px
transform rotate(-10deg) scaleX(0.75)
&:nth-child(4)
bottom 80px
left 220px
transform rotate(-120deg) scaleX(0.75)
z-index 26
&:nth-child(5)
bottom 75px
left 210px
transform rotate(-30deg) scaleX(0.75)
z-index 25
&:nth-child(6)
bottom 92px
left 280px
transform rotate(35deg) scaleX(0.85)
z-index 30
&:nth-child(7)
bottom 70px
left 300px
transform rotate(-30deg) scaleX(0.75)
z-index 20
.stick
position absolute
width $stick-width
height $stick-height
border-radius $stick-border-radius
box-shadow 0 0 2px 1px rgba(0, 0, 0, 0.1)
background $wood
&:before
content ''
display block
position absolute
bottom 100%
left (30px * $scale)
width (6px * $scale)
height (20px * $scale)
background $wood
border-radius $stick-border-radius
transform translateY(50%) rotate(32deg)
&:after
content ''
display block
position absolute
top 0
right 0
width $stick-height
height @width
background $light-wood
border-radius $stick-border-radius
.stick
transform-origin center center
&:nth-child(1)
left 158px
bottom 164px
transform rotate(-152deg) scaleX(0.8)
z-index 12
&:nth-child(2)
left 180px
bottom 30px
transform rotate(20deg) scaleX(0.9)
&:nth-child(3)
left 400px
bottom 38px
transform rotate(170deg) scaleX(0.9)
&:before
display none
&:nth-child(4)
left 370px
bottom 150px
transform rotate(80deg) scaleX(0.9)
z-index 20
&:before
display none
.fire
.flame
position absolute
transform-origin bottom center
opacity 0.9
&__red
.flame
width $flame-width
border-radius $flame-width
background $red-flame
box-shadow 0 0 80px 18px rgba($red-flame, 0.4)
&:nth-child(1)
left $flame-offset
height 160px
bottom 100px
animation fire $fire-duration 0.15s ease-in-out infinite alternate
&:nth-child(2)
left ($flame-offset + $flame-width)
height 240px
bottom 100px
animation fire $fire-duration 0.35s ease-in-out infinite alternate
&:nth-child(3)
left ($flame-offset + $flame-width * 2)
height 300px
bottom 100px
animation fire $fire-duration 0.1s ease-in-out infinite alternate
&:nth-child(4)
left ($flame-offset + $flame-width * 3)
height 360px
bottom 100px
animation fire $fire-duration 0s ease-in-out infinite alternate
&:nth-child(5)
left ($flame-offset + $flame-width * 4)
height 310px
bottom 100px
animation fire $fire-duration 0.45s ease-in-out infinite alternate
&:nth-child(6)
left ($flame-offset + $flame-width * 5)
height 232px
bottom 100px
animation fire $fire-duration 0.3s ease-in-out infinite alternate
&:nth-child(7)
left ($flame-offset + $flame-width * 6)
height 140px
bottom 100px
animation fire $fire-duration 0.1s ease-in-out infinite alternate
&__orange
.flame
width $flame-width
border-radius $flame-width
background $orange-flame
box-shadow 0 0 80px 18px rgba($orange-flame, 0.4)
&:nth-child(1)
left $flame-offset
height 140px
bottom 100px
animation fire $fire-duration 0.05s ease-in-out infinite alternate
&:nth-child(2)
left ($flame-offset + $flame-width)
height 210px
bottom 100px
animation fire $fire-duration 0.1s ease-in-out infinite alternate
&:nth-child(3)
left ($flame-offset + $flame-width * 2)
height 250px
bottom 100px
animation fire $fire-duration 0.35s ease-in-out infinite alternate
&:nth-child(4)
left ($flame-offset + $flame-width * 3)
height 300px
bottom 100px
animation fire $fire-duration 0.4s ease-in-out infinite alternate
&:nth-child(5)
left ($flame-offset + $flame-width * 4)
height 260px
bottom 100px
animation fire $fire-duration 0.5s ease-in-out infinite alternate
&:nth-child(6)
left ($flame-offset + $flame-width * 5)
height 202px
bottom 100px
animation fire $fire-duration 0.35s ease-in-out infinite alternate
&:nth-child(7)
left ($flame-offset + $flame-width * 6)
height 110px
bottom 100px
animation fire $fire-duration 0.1s ease-in-out infinite alternate
&__yellow
.flame
width $flame-width
border-radius $flame-width
background $yellow-flame
box-shadow 0 0 80px 18px rgba($yellow-flame, 0.4)
&:nth-child(1)
left ($flame-offset + $flame-width)
height 140px
bottom 100px
animation fire $fire-duration 0.6s ease-in-out infinite alternate
&:nth-child(2)
left ($flame-offset + $flame-width * 2)
height 172px
bottom 120px
animation fire $fire-duration 0.4s ease-in-out infinite alternate
&:nth-child(3)
left ($flame-offset + $flame-width * 3)
height 240px
bottom 100px
animation fire $fire-duration 0.38s ease-in-out infinite alternate
&:nth-child(4)
left ($flame-offset + $flame-width * 4)
height 200px
bottom 100px
animation fire $fire-duration 0.22s ease-in-out infinite alternate
&:nth-child(5)
left ($flame-offset + $flame-width * 5)
height 142px
bottom 100px
animation fire $fire-duration 0.18s ease-in-out infinite alternate
&__white
.flame
width $flame-width
border-radius $flame-width
background $white-flame
box-shadow 0 0 80px 18px rgba($white-flame, 0.4)
&:nth-child(1)
left $flame-offset + (18px * $scale)
width $small-flame-width
height 100px
bottom 100px
animation fire $fire-duration 0.22s ease-in-out infinite alternate
&:nth-child(2)
left ($flame-offset + $flame-width - (5px * $scale))
width $small-flame-width
height 120px
bottom 100px
animation fire $fire-duration 0.42s ease-in-out infinite alternate
&:nth-child(3)
left ($flame-offset + $flame-width * 2)
height 170px
bottom 100px
animation fire $fire-duration 0.32s ease-in-out infinite alternate
&:nth-child(4)
left ($flame-offset + $flame-width * 3)
height 210px
bottom 100px
animation fire $fire-duration 0.8s ease-in-out infinite alternate
&:nth-child(5)
left ($flame-offset + $flame-width * 4)
height 170px
bottom 100px
animation fire $fire-duration 0.85s ease-in-out infinite alternate
&:nth-child(6)
left ($flame-offset + $flame-width * 5)
width $small-flame-width
height 110px
bottom 100px
animation fire $fire-duration 0.64s ease-in-out infinite alternate
&:nth-child(7)
left ($flame-offset + $flame-width * 6 - (18px * $scale))
width $small-flame-width
height 100px
bottom 100px
animation fire $fire-duration 0.32s ease-in-out infinite alternate
.spark
position absolute
width $spark-width
height $spark-height
background $white-flame
border-radius $spark-border-radius
z-index 50
transform-origin bottom center
transform scaleY(0)
&:nth-child(1)
left 160px
bottom 212px
animation spark 1s 0.4s linear infinite
&:nth-child(2)
left 180px
bottom 240px
animation spark 1s 1s linear infinite
&:nth-child(3)
left 208px
bottom 320px
animation spark 1s 0.8s linear infinite
&:nth-child(4)
left 310px
bottom 400px
animation spark 1s 2s linear infinite
&:nth-child(5)
left 360px
bottom 380px
animation spark 1s 0.75s linear infinite
&:nth-child(6)
left 390px
bottom 320px
animation spark 1s 0.65s linear infinite
&:nth-child(7)
left 400px
bottom 280px
animation spark 1s 1s linear infinite
&:nth-child(8)
left 430px
bottom 210px
animation spark 1s 1.4s linear infinite
@keyframes fire
0%
transform scaleY(1)
28%
transform scaleY(0.7)
38%
transform scaleY(0.8)
50%
transform scaleY(0.6)
70%
transform scaleY(0.95)
82%
transform scaleY(0.58)
100%
transform scaleY(1)
@keyframes spark
0%
35%
transform scaleY(0) translateY(0)
opacity 0
50%
transform scaleY(1) translateY(0)
opacity 1
70%
transform scaleY(1) translateY(-10px)
opacity 1
75%
transform scaleY(1) translateY(-10px)
opacity 0
100%
transform scaleY(0) translateY(0)
opacity 0
Also see: Tab Triggers