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.
<nav class="menu slide-menu-left">
<ul>
<li><button class="close-menu">← Close</button></li>
<li><a href="#">Broccoli</a></li>
...
</ul>
</nav><!-- /slide menu left -->
<nav class="menu slide-menu-right">
<ul>
<li><button class="close-menu">Close →</button></li>
<li><a href="#">Broccoli</a></li>
...
</ul>
</nav><!-- /slide menu right -->
<nav class="menu slide-menu-top">
<ul>
<li><button class="close-menu">↑ Close</button></li>
<li><a href="#">Broccoli</a></li>
...
</ul>
</nav><!-- /slide menu top -->
<nav class="menu slide-menu-bottom">
<ul>
<li><button class="close-menu">Close ↓</button></li>
<li><a href="#">Broccoli</a></li>
...
</ul>
</nav><!-- /slide menu bottom -->
<nav class="menu push-menu-left">
<ul>
<li><button class="close-menu">← Close</button></li>
<li><a href="#">Broccoli</a></li>
...
</ul>
</nav><!-- /push menu left -->
<nav class="menu push-menu-right">
<ul>
<li><button class="close-menu">Close →</button></li>
<li><a href="#">Broccoli</a></li>
...
</ul>
</nav><!-- /push menu right -->
<nav class="menu push-menu-top">
<ul>
<li><button class="close-menu">↑ Close</button></li>
<li><a href="#">Broccoli</a></li>
...
</ul>
</nav><!-- /push menu top -->
<nav class="menu push-menu-bottom">
<ul>
<li><button class="close-menu">Close ↓</button></li>
<li><a href="#">Broccoli</a></li>
...
</ul>
</nav><!-- /push menu bottom -->
<div id="wrapper">
<div id="main">
<div class="container">
<div class="buttons">
<button class="nav-toggler toggle-slide-left">Slide Menu Left</button>
<button class="nav-toggler toggle-slide-right">Slide Menu Right</button>
<button class="nav-toggler toggle-slide-top">Slide Menu Top</button>
<button class="nav-toggler toggle-slide-bottom">Slide Menu Bottom</button>
<button class="nav-toggler toggle-push-left">Push Menu Left</button>
<button class="nav-toggler toggle-push-right">Push Menu Right</button>
<button class="nav-toggler toggle-push-top">Push Menu Top</button>
<button class="nav-toggler toggle-push-bottom">Push Menu Bottom</button>
</div><!-- /buttons -->
<section class="content">
<h1>Vegetables</h1>
<p>Turnip greens yarrow...</p>
</section><!-- /.content -->
</div>
</div><!-- #main -->
</div><!-- /#wrapper -->
body {
overflow-x: hidden;
}
#wrapper {
position: relative;
z-index: 10;
top: 0;
left: 0;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
section {
margin-bottom: 30px;
}
section h1 {
font-family: "Oswald", sans-serif;
margin-bottom: 10px;
}
section p {
margin-bottom: 30px;
}
section p:last-child {
margin-bottom: 0;
}
section:last-child {
margin-bottom: 0;
}
section.toggle {
text-align: center;
}
.mask {
position: fixed;
top: 0;
left: 0;
z-index: 15;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
}
/* Menus */
/* general style for all menus */
nav.menu {
position: fixed;
z-index: 20;
background-color: #67b5d1;
overflow: hidden;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
nav.menu ul {
list-style-type: none;
margin: 0;
padding: 0;
}
nav.menu a {
font-weight: 300;
color: #fff;
}
button.close-menu {
background-color: #3184a1;
color: #fff;
}
button.close-menu:focus {
outline: none;
}
nav.slide-menu-left {
top: 0;
width: 300px;
height: 100%;
}
nav.slide-menu-left li {
display: block;
text-align: center;
border-bottom: solid 1px #3184a1;
border-top: solid 1px #b5dbe9;
}
nav.slide-menu-left li:first-child {
border-top: none;
}
nav.slide-menu-left li:last-child {
border-bottom: none;
}
nav.slide-menu-left a {
display: block;
padding: 10px;
font-size: 18px;
}
nav.slide-menu-left button.close-menu {
margin: 10px 0;
padding: 10px 30px;
background-color: #3184a1;
color: #fff;
}
nav.slide-menu-left {
left: -300px;
}
body.sml-open nav.slide-menu-left {
left: 0;
}
nav.slide-menu-right {
top: 0;
width: 300px;
height: 100%;
}
nav.slide-menu-right li {
display: block;
text-align: center;
border-bottom: solid 1px #3184a1;
border-top: solid 1px #b5dbe9;
}
nav.slide-menu-right li:first-child {
border-top: none;
}
nav.slide-menu-right li:last-child {
border-bottom: none;
}
nav.slide-menu-right a {
display: block;
padding: 10px;
font-size: 18px;
}
nav.slide-menu-right button.close-menu {
margin: 10px 0;
padding: 10px 30px;
background-color: #3184a1;
color: #fff;
}
nav.slide-menu-right {
right: -300px;
}
body.smr-open nav.slide-menu-right {
right: 0;
}
/**/
nav.slide-menu-top {
left: 0;
width: 100%;
height: 100px;
}
nav.slide-menu-top ul {
text-align: center;
padding: 25px 0 0 0;
}
nav.slide-menu-top li {
display: inline-block;
margin: 0;
vertical-align: middle;
}
nav.slide-menu-top a {
display: block;
line-height: 50px;
padding: 0 10px;
font-size: 18px;
}
nav.slide-menu-top button.close-menu {
display: block;
line-height: 50px;
margin: 0;
padding: 0 10px;
}
nav.slide-menu-top {
top: -100px;
}
body.smt-open nav.slide-menu-top {
top: 0;
}
/**/
nav.slide-menu-bottom {
left: 0;
width: 100%;
height: 100px;
}
nav.slide-menu-bottom ul {
text-align: center;
padding: 25px 0 0 0;
}
nav.slide-menu-bottom li {
display: inline-block;
margin: 0;
vertical-align: middle;
}
nav.slide-menu-bottom a {
display: block;
line-height: 50px;
padding: 0 10px;
font-size: 18px;
}
nav.slide-menu-bottom button.close-menu {
display: block;
line-height: 50px;
margin: 0;
padding: 0 10px;
}
nav.slide-menu-bottom {
bottom: -100px;
}
body.smb-open nav.slide-menu-bottom {
bottom: 0;
}
/**/
nav.push-menu-left {
top: 0;
width: 300px;
height: 100%;
}
nav.push-menu-left li {
display: block;
text-align: center;
border-bottom: solid 1px #3184a1;
border-top: solid 1px #b5dbe9;
}
nav.push-menu-left li:first-child {
border-top: none;
}
nav.push-menu-left li:last-child {
border-bottom: none;
}
nav.push-menu-left a {
display: block;
padding: 10px;
font-size: 18px;
}
nav.push-menu-left button.close-menu {
margin: 10px 0;
padding: 10px 30px;
background-color: #3184a1;
color: #fff;
}
nav.push-menu-left {
left: -300px;
}
body.pml-open nav.push-menu-left {
left: 0;
}
body.pml-open #wrapper {
left: 300px;
}
/**/
nav.push-menu-right {
top: 0;
width: 300px;
height: 100%;
}
nav.push-menu-right li {
display: block;
text-align: center;
border-bottom: solid 1px #3184a1;
border-top: solid 1px #b5dbe9;
}
nav.push-menu-right li:first-child {
border-top: none;
}
nav.push-menu-right li:last-child {
border-bottom: none;
}
nav.push-menu-right a {
display: block;
padding: 10px;
font-size: 18px;
}
nav.push-menu-right button.close-menu {
margin: 10px 0;
padding: 10px 30px;
background-color: #3184a1;
color: #fff;
}
nav.push-menu-right {
right: -300px;
}
body.pmr-open nav.push-menu-right {
right: 0;
}
body.pmr-open #wrapper {
left: -300px;
}
/**/
nav.push-menu-top {
left: 0;
width: 100%;
height: 100px;
}
nav.push-menu-top ul {
text-align: center;
padding: 25px 0 0 0;
}
nav.push-menu-top li {
display: inline-block;
margin: 0;
vertical-align: middle;
}
nav.push-menu-top a {
display: block;
line-height: 50px;
padding: 0 10px;
font-size: 18px;
}
nav.push-menu-top button.close-menu {
display: block;
line-height: 50px;
margin: 0;
padding: 0 10px;
}
nav.push-menu-top {
top: -100px;
}
body.pmt-open nav.push-menu-top {
top: 0;
}
body.pmt-open #wrapper {
top: 100px;
}
/**/
nav.push-menu-bottom {
left: 0;
width: 100%;
height: 100px;
}
nav.push-menu-bottom ul {
text-align: center;
padding: 25px 0 0 0;
}
nav.push-menu-bottom li {
display: inline-block;
margin: 0;
vertical-align: middle;
}
nav.push-menu-bottom a {
display: block;
line-height: 50px;
padding: 0 10px;
font-size: 18px;
}
nav.push-menu-bottom button.close-menu {
display: block;
line-height: 50px;
margin: 0;
padding: 0 10px;
}
nav.push-menu-bottom {
bottom: -100px;
}
body.pmb-open nav.push-menu-bottom {
bottom: 0;
}
body.pmb-open #wrapper {
top: -100px;
}
// classie js
!function(s){"use strict";function n(s){return new RegExp("(^|\\s+)"+s+"(\\s+|$)")}var a,e,c;"classList"in document.documentElement?(a=function(s,n){return s.classList.contains(n)},e=function(s,n){s.classList.add(n)},c=function(s,n){s.classList.remove(n)}):(a=function(s,a){return n(a).test(s.className)},e=function(s,n){a(s,n)||(s.className=s.className+" "+n)},c=function(s,a){s.className=s.className.replace(n(a)," ")}),s.classie={hasClass:a,addClass:e,removeClass:c,has:a,add:e,remove:c}}(window);
// end of classie js
(function( window ){
'use strict';
var body = document.body,
mask = document.createElement("div"),
toggleSlideLeft = document.querySelector( ".toggle-slide-left" ),
toggleSlideRight = document.querySelector( ".toggle-slide-right" ),
toggleSlideTop = document.querySelector( ".toggle-slide-top" ),
toggleSlideBottom = document.querySelector( ".toggle-slide-bottom" ),
togglePushLeft = document.querySelector( ".toggle-push-left" ),
togglePushRight = document.querySelector( ".toggle-push-right" ),
togglePushTop = document.querySelector( ".toggle-push-top" ),
togglePushBottom = document.querySelector( ".toggle-push-bottom" ),
slideMenuLeft = document.querySelector( ".slide-menu-left" ),
slideMenuRight = document.querySelector( ".slide-menu-right" ),
slideMenuTop = document.querySelector( ".slide-menu-top" ),
slideMenuBottom = document.querySelector( ".slide-menu-bottom" ),
pushMenuLeft = document.querySelector( ".push-menu-left" ),
pushMenuRight = document.querySelector( ".push-menu-right" ),
pushMenuTop = document.querySelector( ".push-menu-top" ),
pushMenuBottom = document.querySelector( ".push-menu-bottom" ),
activeNav
;
mask.className = "mask";
/* slide menu left */
toggleSlideLeft.addEventListener( "click", function(){
classie.add( body, "sml-open" );
document.body.appendChild(mask);
activeNav = "sml-open";
} );
/* slide menu right */
toggleSlideRight.addEventListener( "click", function(){
classie.add( body, "smr-open" );
document.body.appendChild(mask);
activeNav = "smr-open";
} );
/* slide menu top */
toggleSlideTop.addEventListener( "click", function(){
classie.add( body, "smt-open" );
document.body.appendChild(mask);
activeNav = "smt-open";
} );
/* slide menu bottom */
toggleSlideBottom.addEventListener( "click", function(){
classie.add( body, "smb-open" );
document.body.appendChild(mask);
activeNav = "smb-open";
} );
/* push menu left */
togglePushLeft.addEventListener( "click", function(){
classie.add( body, "pml-open" );
document.body.appendChild(mask);
activeNav = "pml-open";
} );
/* push menu right */
togglePushRight.addEventListener( "click", function(){
classie.add( body, "pmr-open" );
document.body.appendChild(mask);
activeNav = "pmr-open";
} );
/* push menu top */
togglePushTop.addEventListener( "click", function(){
classie.add( body, "pmt-open" );
document.body.appendChild(mask);
activeNav = "pmt-open";
} );
/* push menu bottom */
togglePushBottom.addEventListener( "click", function(){
classie.add( body, "pmb-open" );
document.body.appendChild(mask);
activeNav = "pmb-open";
} );
/* hide active menu if mask is clicked */
mask.addEventListener( "click", function(){
classie.remove( body, activeNav );
activeNav = "";
document.body.removeChild(mask);
} );
/* hide active menu if close menu button is clicked */
[].slice.call(document.querySelectorAll(".close-menu")).forEach(function(el,i){
el.addEventListener( "click", function(){
classie.remove( body, activeNav );
activeNav = "";
document.body.removeChild(mask);
} );
});
})( window );
Also see: Tab Triggers