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.
<!--
Originally by phpacademy Youtube channel
Create A Slide Out Menu With CSS
https://www.youtube.com/watch?v=JTTLh1PU3mY
-->
<html>
<head>
<title>Slide Out Menu</title>
</head>
<body>
<nav class="nav-side">
Side content
<a href="#" class="nav-toggle"></a>
</nav>
<div class="wrapper">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam scelerisque, libero accumsan tempus convallis, neque urna eleifend elit, a malesuada orci massa sed turpis. Nulla scelerisque non augue ac imperdiet. Integer condimentum vitae leo sed fermentum. Nullam tincidunt nisl eget porta auctor. Morbi vestibulum bibendum pulvinar. Nunc condimentum tempor dolor, eu pretium nisi fringilla nec. Morbi cursus ante at metus venenatis placerat. Morbi nec ligula finibus, commodo lacus id, rhoncus felis. Cras ut vestibulum nisi, rutrum convallis magna. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
<p>Vivamus sed tristique velit. Maecenas accumsan elit in urna suscipit, vitae ultricies nunc dapibus. Fusce ultrices est in sem ultrices, ut auctor tortor efficitur. Suspendisse ullamcorper sit amet lorem non consequat. Maecenas non velit placerat, aliquet massa in, rhoncus nulla. Ut eu est vitae ligula blandit dictum quis in enim. Pellentesque sit amet tincidunt augue. Donec id urna ante. Integer fermentum ipsum ac dolor gravida interdum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</p>
<p>Nullam suscipit congue nulla et dictum. Duis euismod arcu velit, non aliquam dui lobortis eget. Aenean accumsan consectetur volutpat. Morbi lobortis enim ut sapien fermentum, sed rhoncus quam tincidunt. Cras consectetur, turpis et elementum mattis, sapien magna tincidunt lacus, id lobortis est augue quis dui. Sed in arcu commodo, mollis arcu vitae, viverra turpis. Praesent aliquet ullamcorper enim in faucibus. Nunc in dolor sit amet mi luctus fringilla nec non tortor. In pharetra ut mi et porta. Nam gravida orci porttitor tellus pulvinar ornare. Nulla ornare luctus placerat. Cras ac lacus lacinia, dictum velit aliquam, varius nisl. Fusce sollicitudin lorem efficitur dui lacinia gravida. Ut augue mauris, tempor at sapien vel, tempor efficitur leo. Mauris congue velit sit amet magna condimentum vestibulum. Sed vel consectetur ante.</p>
<p>Morbi eget dapibus quam, quis feugiat ex. Sed id quam tellus. Nam at consectetur neque, vel vestibulum ipsum. Aliquam varius lectus quis mauris porttitor faucibus. Aliquam porta ullamcorper mauris, blandit malesuada nisi semper vel. Curabitur in condimentum ipsum, in maximus justo. Donec iaculis odio vehicula, interdum velit at, molestie turpis.</p>
<p>Mauris sed viverra magna. In molestie lobortis nisi, sit amet dapibus erat pharetra ac. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam non laoreet sapien, vel fringilla ex. Fusce aliquam nulla in ante pulvinar, eget mollis libero dapibus. Nunc consectetur, est vehicula vestibulum sodales, risus mauris posuere nulla, quis sodales ex nulla in augue. Curabitur viverra urna eu odio pulvinar cursus. Suspendisse condimentum odio at ligula rutrum, vel varius purus tempor. Nulla et accumsan nisi.</p>
</div>
</body>
</html>
body {
font: 1em "Helvetica", sans-serif;
line-height: 1.4;
font-weight: 200;
}
.wrapper {
margin-left: 50px;
}
.nav-side {
position: fixed;
left: 0;
top: 0;
height: 100%;
width: 100%;
max-width: 250px;
background-color: cornflowerblue;
box-sizing: border-box;
padding: 20px;
color: white;
margin-left: -250px;
transition: margin 200ms ease-in-out;
}
.nav-side.nav-open {
margin-left: 0;
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
}
.nav-toggle {
position: absolute;
right: -40px;
top: 0;
width: 40px;
height: 40px;
background-color: cornflowerblue;
text-decoration: none;
text-align: center;
border-bottom-right-radius: 3px;
box-shadow: 1px 0 3px rgba(0, 0, 0, 0.1);
}
.nav-toggle:before {
content: "\2192";
font-weight: 600;
color: white;
line-height: 40px;
}
.nav-side.nav-open .nav-toggle:before {
content: "\2190";
}
$(".nav-side .nav-toggle").on("click", function(e) {
e.preventDefault();
$(this).parent().toggleClass("nav-open");
});
Also see: Tab Triggers