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.
<header class="header">
<div class="hamburger">
<div class="hamburger-box">
<div class="hamburger-inner"></div>
</div>
</div>
</header>
<nav class="navbar" role="navigation">
<ul class="menu">
<li class="menu-item"><a href="#">menu item</a></li>
<li class="menu-item"><a href="#">menu item</a></li>
<li class="menu-item"><a href="#">menu item</a></li>
<li class="menu-item"><a href="#">menu item</a></li>
</ul>
</nav>
<div class="backdrop"></div>
<main class="main">
<h1 class="main-title">My awesome menu</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Officiis, autem mollitia? Rem tenetur sequi dolorem quis ab libero possimus minima, consequuntur repudiandae quibusdam. Voluptatibus facere mollitia, iure qui minima aut numquam enim ipsum quis laboriosam obcaecati quasi a, et voluptatum.</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, cum voluptatum vel recusandae, doloribus necessitatibus, aspernatur doloremque corporis labore perspiciatis libero ipsam? Fugit commodi omnis culpa, voluptates odit earum nisi hic nostrum nesciunt ut nihil labore rerum, unde ratione asperiores optio soluta ducimus error dolorem accusamus. Vel dolores nostrum, a quas deleniti totam perspiciatis, ab voluptatem maiores in eos sint incidunt? Repellendus nam ab veniam iste, omnis veritatis impedit quos earum, quibusdam velit aspernatur ipsum! Veniam optio tempora iusto omnis autem nobis voluptas officia placeat ea, sunt ratione asperiores repellendus qui facilis, exercitationem cumque non perferendis vero. Repellat, perferendis? Nam.</p>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Aliquid temporibus sed est quo sequi, quae accusantium quidem harum deleniti culpa, minima tempore dolor? Illum, enim eos? Assumenda minus sint excepturi harum enim fugiat possimus. Obcaecati voluptatum sequi quis minima. Odio officiis ullam dolore, doloribus incidunt vero corporis aliquid, animi dolor dolorum ipsam ea alias omnis voluptatem inventore laborum quam a. Quam earum distinctio blanditiis minima magni saepe molestias perferendis sit inventore expedita, autem consectetur, quidem quod dignissimos dicta doloremque? Reiciendis, fugiat deserunt rerum voluptate temporibus rem soluta quaerat? Recusandae laborum voluptate possimus temporibus provident inventore architecto distinctio sit assumenda nobis.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia cum illum nobis quos facilis, beatae laborum eaque dolorem, fugiat neque, veniam ipsa? Fuga atque doloremque dolorum, explicabo animi porro tempora nulla sit molestias magnam est voluptatibus ratione dicta minima repellendus quas! Veritatis vel tenetur debitis, eos nesciunt vero laudantium numquam dolorum unde maxime, excepturi deleniti velit corporis eius aliquam nobis possimus non nisi illo dolor animi nihil quidem incidunt. Mollitia voluptate at voluptates rem maiores ad sunt eos assumenda obcaecati. Laudantium labore fugiat, perferendis magni eum harum reiciendis nam autem totam natus cumque dolore amet sint soluta et! Cum, laboriosam.</p>
</main>
@import url("https://fonts.googleapis.com/css?family=Lato");
html {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
font-family: "Lato", sans-serif;
line-height: 1.15; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
-ms-text-size-adjust: 100%;
-ms-overflow-style: scrollbar;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
/* Font rendering */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-rendering: optimizeLegibility;
}
*,
*::before,
*::after {
-webkit-box-sizing: inherit;
-moz-box-sizing: inherit;
-ms-box-sizing: inherit;
box-sizing: inherit;
margin: 0;
padding: 0;
border: 0;
}
body {
color: #fff;
background-color: #282c34;
overflow: hidden;
transition: transform 300ms ease-in-out;
}
a {
text-decoration: none;
color: inherit;
text-transform: uppercase;
}
.header {
background-color: #fff;
}
.navbar {
position: fixed;
top: 0;
left: 0;
z-index: 1000;
transform: translate3d(-100%, 0, 0);
height: 100vh;
width: 300px;
background-color: #fafafa;
transition: 0.1s ease-in;
overflow-y:auto;
}
.main {
text-align: justify;
margin: auto;
max-width: 80%;
}
.main {
padding: 10px;
}
.main-title {
text-align: center;
}
.open {
transform: translate3d(0, 0, 0);
transition: 0.05s;
}
.menu {
color: #333;
}
.menu-item {
display: block;
margin-top: 1rem;
padding-top: 10px;
padding-left: 10px;
}
.hamburger {
padding: 15px 15px;
display: inline-block;
cursor: pointer;
transition-property: opacity, filter;
transition-duration: 0.15s;
transition-timing-function: linear;
font: inherit;
color: inherit;
text-transform: none;
background-color: transparent;
border: 0;
margin: 0;
overflow: visible;
}
.hamburger:hover {
opacity: 0.7;
}
.hamburger.is-active:hover {
opacity: 0.7;
}
.hamburger.is-active .hamburger-inner,
.hamburger.is-active .hamburger-inner::before,
.hamburger.is-active .hamburger-inner::after {
background-color: #000;
}
.hamburger-box {
width: 40px;
height: 24px;
display: inline-block;
position: relative;
}
.hamburger-inner {
display: block;
top: 50%;
margin-top: -2px;
}
.hamburger-inner,
.hamburger-inner::before,
.hamburger-inner::after {
width: 40px;
height: 4px;
background-color: #000;
border-radius: 4px;
position: absolute;
transition-property: transform;
transition-duration: 0.15s;
transition-timing-function: ease;
}
.hamburger-inner::before,
.hamburger-inner::after {
content: "";
display: block;
}
.hamburger-inner::before {
top: -10px;
}
.hamburger-inner::after {
bottom: -10px;
}
.translate {
transform: translate3d(300px, 0, 0);
}
.backdrop {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.5);
opacity: 0;
transition: 0.15s ease-in-out;
z-index: -1;
pointer-events: none;
}
.backdrop.show {
pointer-events: auto;
opacity: 1;
z-index: 100;
}
!(function(w, d){
const navbar = d.querySelector('.navbar')
const body = d.body
const toggle = d.querySelector('.hamburger')
const backdrop = d.querySelector('.backdrop')
toggle.addEventListener('click', () =>{
body.classList.toggle('translate')
backdrop.classList.toggle('show')
})
backdrop.addEventListener('click', function(e){
if(e.target === this){
body.classList.toggle('translate')
backdrop.classList.toggle('show')
}
})
})(window, document)
Also see: Tab Triggers