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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.
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.
If the stylesheet 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 CSS 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.
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.
<html>
<head>
<title>Mobile first navigation menu</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
</head>
<body>
<input type="checkbox" id="show-menu">
<div id="fix-bar">
<div class="logo">
<a href="/">logo</a>
</div>
<div class="push">
<label class="hamburguer" for="show-menu">
<span></span>
<span></span>
<span></span>
<span></span>
</label>
</div>
</div>
<div id="canvas">
<div id="nav">
<ul class="site-menu">
<li><a href="#/work">Work</a></li>
<li class="has-sub"><a href="#/about">About</a></li>
<li><a href="#/careers">Careers</a></li>
<li><a href="#/ideas">Ideas</a></li>
<li><a href="#/news">News</a></li>
<li><a href="#/events">Events</a></li>
<li><a href="#/contact">Contact</a></li>
<li class="copy">© 2016 Logo. All Rights Reserved.</li>
</ul>
</div>
<label for="show-menu" class="mask"></label>
<div id="content">
<h1>Lorem ipsum dolor sit amet</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. In ut rerum voluptatum, expedita, ab perspiciatis nulla omnis veritatis, dignissimos explicabo officia neque eos. Itaque, reiciendis corrupti quos. Ipsa, non, itaque!</p>
<p>Illum minima praesentium reiciendis iure voluptatem, maxime accusamus temporibus, quisquam nihil nostrum placeat, repudiandae facere. Nihil odio quia omnis iure temporibus. Ullam itaque consequatur eveniet voluptatem nam, suscipit nesciunt iste!</p>
<p>Est eum delectus officia. Sequi hic reiciendis est ullam aliquid rem voluptates deserunt! Accusamus, consequuntur! Delectus distinctio doloremque possimus provident qui rerum id. Molestiae, impedit, porro nisi repellat atque esse.</p>
<p>At possimus commodi dolorum hic dicta unde ipsam sequi laborum! Dignissimos tempora facere dolore ipsam eligendi repudiandae, ipsa placeat doloribus cumque quod dolores ab, ea labore incidunt ex sapiente! Possimus.</p>
<p>Maxime beatae quia similique error quod cumque dicta facere, consequuntur quos? Alias ducimus aliquam commodi quis veritatis, beatae libero iure culpa id reiciendis ratione. Dolorum voluptatibus iusto id accusantium adipisci.</p>
<p>Accusantium molestias velit ut voluptate adipisci sit possimus id. Consequuntur debitis suscipit ducimus nemo officia dolor voluptates saepe doloribus corporis dolorem autem, quasi, tempore maxime sapiente deleniti rem, a. Nesciunt.</p>
<p>Nemo animi vitae fuga repellendus sequi, laborum voluptates molestias quo reprehenderit tenetur libero non quis deserunt veritatis culpa tempora a, voluptatem itaque. Totam atque id, praesentium corporis eaque dignissimos sed.</p>
<p>Pariatur omnis expedita voluptates, aut laborum consequatur repudiandae aperiam, delectus voluptate, saepe ea magnam distinctio dolorum a reiciendis suscipit. Corporis ex animi reiciendis vero natus porro, tenetur dignissimos blanditiis quis?</p>
<p>Adipisci dicta vitae, totam quisquam, aliquam sint non qui hic est beatae architecto laboriosam in. Sed at, pariatur doloremque libero facere voluptates culpa dolore. Quo debitis similique culpa quis fuga?</p>
<p>Non ipsum porro perferendis pariatur, harum iusto amet dolore quasi aut quidem quod laboriosam libero odit accusamus animi, cumque ea commodi corporis, sequi eaque numquam aliquam! Consequuntur, animi dolorum debitis?</p>
</div>
</div>
</body>
</html>
@import url(https://fonts.googleapis.com/css?family=Montserrat:700)
$nav-width = 250px
$magenta = #00a8eb
$timing = 0.5s
$ease = ease
*
margin 0
padding 0
box-sizing border-box
html
body
height 100%
body
font-family 'Helvetica Neue', Helvetica, sans-serif
#fix-bar
position fixed
top 0
left 0
z-index 9
width 100%
height 60px
background-color $magenta
.logo
position absolute
left 0
width $nav-width
transform translate3d(-50%, 0, 0)
transition transform $timing $ease
a
display block
color #fff
text-decoration none
text-transform uppercase
line-height 24px
width 60px
height 24px
padding 18px 16px 18px 24px
box-sizing content-box
.push
position relative
left 0
height 100%
background-color $magenta
transition transform $timing $ease
.hamburguer
width 72px
height 60px
display block
position relative
cursor pointer
span
display block
position absolute
height 4px
width 24px
background #fff
opacity 1
left 24px
transform rotate(0deg)
transition .3s ease-in-out
&:nth-child(1)
top 20px
&:nth-child(2)
&:nth-child(3)
top 28px
&:nth-child(4)
top 36px
#canvas
position relative
height 100%
padding-top 60px
overflow hidden
#nav
overflow-y scroll
position absolute
left 0
height 100%
width $nav-width
transform translate3d(-50%, 0, 0)
transition transform $timing $ease
padding-top 12px
padding-bottom 60px // fix bar
a
text-decoration none
color #000
display block
padding 14px 24px
font 20px/1 'Montserrat', sans-serif
font-weight 700
&:hover
background-color #eee
.site-menu
position relative
min-height 100%
padding-bottom 60px // copy height
.copy
position absolute
bottom 0
padding 16px 24px
font-size 12px
line-height 1.4
#content
background-color #fff
overflow-y scroll
position relative
left 0
height 100%
transition transform $timing $ease
transform translate3d(0, 0, 0)
padding 20px
.mask
position absolute
top 60px
left 0
z-index -1
width 100%
height 100%
opacity 0
transition opacity $timing $ease, transform $timing $ease, z-index 0s $timing
background-color rgba(0, 0, 0, 0.5)
// trigger menu
input#show-menu
position absolute
opacity 0
// show mobile nav
input#show-menu:checked ~
#fix-bar
.push
transform translate3d($nav-width, 0, 0)
.hamburguer span
&:nth-child(1)
&:nth-child(4)
top 28px
width 0
left 50%
&:nth-child(2)
transform rotate(45deg)
&:nth-child(3)
transform rotate(-45deg)
#canvas
.mask
z-index 1
opacity 1
transform translate3d($nav-width, 0, 0)
transition opacity $timing $ease, transform $timing $ease
#nav
^[0] #fix-bar .logo
transform translate3d(0, 0, 0)
#content
transform translate3d($nav-width, 0, 0)
// TODO refact stylus
Also see: Tab Triggers