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 URL's 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 it's URL and the proper URL extention.
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.
<div class="burger-toggle">
<input class="burger-toggle__checkbox" type="checkbox"/><svg
class="worktop"
viewBox="0 0 400 100"
preserveAspectRatio="xMinYMin">
<defs
id="defs4">
<pattern
patternTransform="matrix(1.301894,-0.34884141,15.183253,56.664678,29.525874,0.55709196)"
id="pattern5770"
xlink:href="#Strips1_10" />
<pattern
patternUnits="userSpaceOnUse"
width="11"
height="1"
patternTransform="translate(0,0) scale(10,10)"
id="Strips1_10">
<rect
style="fill:black;stroke:none"
x="0"
y="-0.5"
width="1"
height="2"
id="rect4943" />
</pattern>
<pattern
patternTransform="matrix(9.6592583,-2.5881905,2.5881905,9.6592583,3.6640572e-6,-952.36206)"
id="pattern5671"
xlink:href="#Checkerboardwhite" />
<pattern
patternUnits="userSpaceOnUse"
width="2"
height="2"
patternTransform="translate(0,0) scale(10,10)"
id="Checkerboardwhite">
<rect
style="fill:white;stroke:none"
x="0"
y="0"
width="1"
height="1"
id="rect4981" />
<rect
style="fill:white;stroke:none"
x="1"
y="1"
width="1"
height="1"
id="rect4983" />
</pattern>
</defs>
<g
id="layer2">
<rect
y="0"
x="0"
height="100"
width="400"
id="rect5674"
style="fill:#b2967a;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
style="opacity:0.3;fill:url(#pattern5770);fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect5676"
width="400"
height="100"
x="0"
y="0" />
</g>
<g
transform="translate(0,-952.36209)"
id="layer1">
<path
id="rect4178"
transform="translate(0,952.36209)"
d="M 0,0 0,100 120.8457,100 94.050781,0 0,0 Z"
style="fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.59430015;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
id="rect5663"
transform="translate(0,952.36209)"
d="M 0,0 0,100 120.8457,100 94.050781,0 0,0 Z"
style="fill:url(#pattern5671);fill-opacity:1;stroke:none;stroke-width:0.59430015;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
id="rect5991"
transform="translate(0,952.36209)"
d="m 244.83594,0 26.79297,100 128.32031,0 0,-100 -155.11328,0 z"
style="opacity:1;fill:#666666;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
<g
id="layer3">
<circle
r="50"
cy="50"
cx="50"
id="path5775"
style="opacity:1;fill:#bfbfbf;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
<g
id="layer4">
<path
id="rect5780"
d="M 268.41797,0 295.21484,100 400,100 400,0 268.41797,0 Z"
style="fill:#333333;fill-opacity:1;stroke:none;stroke-width:0.69435036;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
id="rect5791"
d="m 306.11914,0 -21.35742,5.7226562 c -1.63527,0.4381717 -2.59833,2.1069048 -2.16016,3.7421876 0.43817,1.6352812 2.1069,2.6002832 3.74219,2.1621092 L 329.73242,0 306.11914,0 Z"
style="opacity:1;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
id="rect5795"
d="m 400,70.037109 -91.43945,24.503907 c -1.63528,0.438173 -2.60028,2.106905 -2.16211,3.742187 0.19641,0.733038 0.64745,1.319815 1.22461,1.716797 l 4.16601,0 L 400,76.367188 l 0,-6.330079 z"
style="opacity:1;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
id="rect5805"
d="M 400,85.904297 347.39648,100 371.00977,100 400,92.232422 l 0,-6.328125 z"
style="opacity:1;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
id="rect5807"
d="M 399.99987,54.171726 304.59313,79.73754 c -1.63527,0.438172 -2.59978,2.10715 -2.16161,3.742431 0.43817,1.635283 2.10967,2.599795 3.74495,2.161621 l 93.8234,-25.141561 0,-6.328296 z"
style="opacity:1;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
id="rect5809"
d="m 399.99987,38.30553 -99.37394,26.628826 c -1.63529,0.438175 -2.59727,2.10715 -2.1591,3.742433 0.43817,1.635282 2.10716,2.599795 3.74243,2.161621 l 97.79058,-26.204669 10e-6,-6.328297 z"
style="opacity:1;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
id="rect5811"
d="m 399.10846,22.744893 c -0.20301,0.01242 -0.4067,0.04371 -0.61111,0.09848 L 296.66127,50.131306 c -1.63528,0.438173 -2.59979,2.107155 -2.16162,3.742433 0.43817,1.635282 2.10716,2.599793 3.74244,2.161622 l 101.75776,-27.267775 1e-5,-5.931832 c -0.28852,-0.06939 -0.58565,-0.109562 -0.89141,-0.09091 z"
style="opacity:1;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
id="rect5813"
d="m 365.33008,0 -76.60156,20.525391 c -1.63529,0.438172 -2.60029,2.106906 -2.16211,3.742187 0.43817,1.635281 2.1069,2.600282 3.74218,2.16211 L 388.94727,0 365.33008,0 Z"
style="opacity:1;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
transform="matrix(0.96592583,-0.25881905,0.25881905,0.96592583,0,0)"
ry="3.0558977"
y="109.87924"
x="270.5213"
height="6.1117954"
width="111.54027"
id="rect5815"
style="opacity:1;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</svg>
<svg
class="patty"
preserveAspectRatio="xMinYMin"
viewBox="0 0 70 70">
<g
id="g4827">
<g
transform="translate(-315,-15)"
id="layer5">
<circle
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
class="patty__meat"
cx="350"
cy="50"
r="35" />
<path
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 361.35156,16.931641 -37.74023,10.111328 a 35,35 0 0 0 -5.05274,7.683593 l 51.08008,-13.6875 a 35,35 0 0 0 -8.28711,-4.107421 z"
class="patty__line" />
<path
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 377.56445,28.453125 315.38477,45.113281 A 35,35 0 0 0 315,50 a 35,35 0 0 0 0.0547,1.529297 l 65.9785,-17.679688 a 35,35 0 0 0 -3.46875,-5.396484 z"
class="patty__line" />
<path
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 384.1543,42.550781 -67.45899,18.076172 a 35,35 0 0 0 2.36914,5.693359 l 65.88867,-17.654296 a 35,35 0 0 0 -0.79882,-6.115235 z"
class="patty__line" />
<path
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 383.91211,58.482422 -59.08008,15.832031 a 35,35 0 0 0 5.75391,4.785156 l 50.74609,-13.597656 a 35,35 0 0 0 2.58008,-7.019531 z"
class="patty__line" />
<path
style="opacity:1;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 371.33203,77.720703 -25.9043,6.941406 A 35,35 0 0 0 350,85 35,35 0 0 0 371.33203,77.720703 Z"
class="patty__line" />
</g>
<circle
style="opacity:1;fill:none;fill-opacity:1;stroke:#111;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="circle4790"
cx="35"
cy="35"
r="33" />
</g>
</svg>
<div class="burger-toggle__border"></div>
</div>
$borderWidth = 5px
$height = 100px
$width = 200px
$pattySize = 70px
$bgColor = #111
$borderColor = #fff
$meatColor = #fb9496
$meatCookedColor = #6d3b12
$meatCookedLinesColor = #311205
$transitionDuration = .5s
$cookingDuration = .25s
*
box-sizing border-box
html
body
align-items center
background-color $bgColor
display flex
justify-content center
margin 0
padding 0
height 100vh
width 100vw
.burger-toggle
border-radius ($height / 2)
height $height
overflow hidden
// Wow. This is an odd one
-webkit-mask-image linear-gradient(0deg, #000, #000)
position relative
width $width
@media(min-width 768px)
$height = 200px
$width = 400px
border-radius ($height / 2)
height $height
width $width
&__border
border-radius ($height / 2)
position absolute
top 0
left 0
right 0
bottom 0
border $borderWidth solid $borderColor
@media(min-width 768px)
$borderWidth = 10px
$height = 200px
border-radius ($height / 2)
border $borderWidth solid $borderColor
&__checkbox
border 0
cursor pointer
height 100%
left 0
margin 0
opacity 0
padding 0
position absolute
top 0
width 100%
z-index 3
&:checked ~ .worktop
transform translateX(-50%)
&:checked ~ .patty
transform translateX(140%)
&:checked ~ .patty .patty__line
&:checked ~ .patty .patty__meat
transition fill $transitionDuration ($transitionDuration + $cookingDuration)
&:checked ~ .patty .patty__line
fill $meatCookedLinesColor
&:checked ~ .patty .patty__meat
fill $meatCookedColor
.worktop
height $height
left 0
position absolute
top 0
transition transform $transitionDuration
width $width * 2
@media(min-width 768px)
$height = 200px
$width = 400px
height $height
width ($width * 2px)
.patty
border-radius 100%
height $pattySize
left (($height - $pattySize) / 2px)
overflow hidden
position absolute
top (($height - $pattySize) / 2px)
transition transform $transitionDuration
@media(min-width 768px)
$height = 200px
$pattySize = 140px
$width = 400px
height $pattySize
left (($height - $pattySize) / 2px)
top (($height - $pattySize) / 2px)
&__line
&__meat
transition fill $transitionDuration
fill $meatColor
Also see: Tab Triggers