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.
<nav class="menu">
<input id ="menu__toggle" type="checkbox" class='menu__toggle'/>
<label for="menu__toggle" class="menu__toggle-label">
<svg preserveAspectRatio='xMinYMin' viewBox='0 0 24 24'>
<path d='M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z' />
</svg>
<svg preserveAspectRatio='xMinYMin' viewBox='0 0 24 24'>
<path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" />
</svg>
</label>
<ol class='menu__content'>
<li class="menu-item"><a href="#0">Home</a></li>
<li class="menu-item"><a href="#0">About</a></li>
<li class="menu-item">
<a href="#0">Widgets</a>
<ol class="sub-menu">
<li class="menu-item"><a href="#0">Big Widgets</a></li>
<li class="menu-item"><a href="#0">Bigger Widgets</a></li>
<li class="menu-item"><a href="#0">Huge Widgets</a></li>
</ol>
</li>
<li class="menu-item">
<a href="#0">Kabobs</a>
<ol class="sub-menu">
<li class="menu-item"><a href="#0">Shishkabobs</a></li>
<li class="menu-item"><a href="#0">BBQ kabobs</a></li>
<li class="menu-item"><a href="#0">Summer kabobs</a></li>
</ol>
</li>
<li class="menu-item"><a href="#0">Contact</a></li>
</ol>
</nav>
@import url('https://fonts.googleapis.com/css?family=Lato');
*
box-sizing border-box
$width = 250px
$duration = .15s
$delayStep = .05s
$baseDelay = 1.5 * $duration
$borderDelay = $baseDelay + (10 * $delayStep) + $duration
html
body
font-family 'Lato', sans-serif
margin 0
min-height 100vh
padding 0
&:before
background linear-gradient(35deg, #9a12b3, #c5eff7)
bottom 0
content ''
height 100vh
left 0
position fixed
top 0
right 0
width 100vw
svg
cursor pointer
height 44px
width 44px
path
fill #fff
ol
list-style-type none
a[href]
color #ffffff
position relative
text-decoration none
&:hover
&:after
transform scaleX(1)
&:after
content ''
position absolute
top 100%
height 4px
background #fff
left 0
right 0
transition transform $duration
transform-origin left
transform scaleX(0)
.menu
position relative
width $width
&__content
color #ffffff
margin 0
padding 0 0 25px 0
position absolute
right 100%
top 0
width $width
z-index 2
&__toggle-label
height 44px
left 0
position absolute
width 44px
svg
left 0
position absolute
top 0
transition transform $duration
z-index 2
&:nth-of-type(2)
left $width
transform scale(0)
&__toggle
opacity 0
position fixed
&:checked ~ .menu__toggle-label
background rgba(0, 0, 0, 0.65)
height 100vh
left 0
position fixed
top 0
transition background $duration
width 100vw
svg:nth-of-type(1)
transform scale(0)
svg:nth-of-type(2)
left $width
transform scale(1)
transition transform $duration
transition-delay $borderDelay + $delayStep
&:checked ~ .menu__content
transform translate(100%, 0)
.menu-item
transform translateX(0)
transition transform $duration cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color $duration
$colors = #9b59b6 #86e2d5 #f5ab35 #1e8bc3 #e26a6a
for $item in (1..5)
&:nth-of-type({$item})
a[href]:after
background $colors[$item - 1]
border-color $colors[$item - 1]
&:nth-of-type(1)
transition-delay ($baseDelay), $borderDelay
&:nth-of-type(2)
transition-delay ($baseDelay + $delayStep), $borderDelay
&:nth-of-type(3)
transition-delay ($baseDelay + (2 * $delayStep)), $borderDelay
.menu-item
&:nth-of-type(1)
transition-delay ($baseDelay + (3 * $delayStep)), $borderDelay
&:nth-of-type(2)
transition-delay ($baseDelay + (4 * $delayStep)), $borderDelay
&:nth-of-type(3)
transition-delay ($baseDelay + (5 * $delayStep)), $borderDelay
&:nth-of-type(4)
transition-delay ($baseDelay + (6 * $delayStep)), $borderDelay
.menu-item
&:nth-of-type(1)
transition-delay ($baseDelay + (7 * $delayStep)), $borderDelay
&:nth-of-type(2)
transition-delay ($baseDelay + (8 * $delayStep)), $borderDelay
&:nth-of-type(3)
transition-delay ($baseDelay + (9 * $delayStep)), $borderDelay
&:nth-of-type(5)
transition-delay ($baseDelay + (10 * $delayStep)), $borderDelay
$itemSize = 44px
.menu__content > .menu-item
border-left 8px solid transparent
> a
line-height $itemSize
min-width 60px
.sub-menu
padding 0 0 0 $itemSize
.menu-item
line-height $itemSize
min-height $itemSize
padding 0 12px
transform translateX(-100%)
.menu-item
transform translateX(-150%)
// NOT FOUND
Also see: Tab Triggers