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.
<div class="wrapper active-element">
<header class="main-header">
<nav>
<div class="masthead active-element">
<h1><a href="#0">Branding</a></h1>
<div id="menu-toggle" class="menu-toggle active-element">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</div>
</div>
<div class="main-nav-list active-element">
<ul>
<li><a href="#0">Demo Reel</a></li>
<li><a href="#0">Faces</a></li>
<li><a href="#0" class="mobile-hide">Blog</a></li>
<li><a href="#0" class="active-link">About</a></li>
<li><a href="#0">Contact</a></li>
</ul>
</div>
</nav>
</header>
<main class="main-contents">
<h2>About</h2>
<p>Woot! Got the (vanilla) Javascript to work!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum labore cumque, laborum, dolorem dolor doloribus iste qui omnis? Consequuntur sapiente mollitia iure quas. Rem nobis tenetur, est accusamus iste dolor, necessitatibus, facilis error ratione aliquid sequi voluptates dignissimos. Quidem, quam, rem? Molestias odio, perferendis dolores doloremque eum quo mollitia atque, sit inventore nisi accusamus magnam vitae temporibus maxime et in aliquam qui aliquid obcaecati alias unde repellat laudantium quam blanditiis. Blanditiis, earum itaque veritatis et numquam culpa, tempore magnam. Quas laborum voluptate id vero. Voluptatibus! Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque nemo reprehenderit nostrum nesciunt, deleniti facere voluptas eligendi expedita dolor at praesentium sequi. Accusamus vitae ut necessitatibus aut, repudiandae voluptate! Excepturi quam explicabo quis illo, qui a ipsam sit atque non sed doloribus maiores in quo ut voluptatem neque animi, saepe facilis nemo et! Temporibus dolores deserunt illo cum aut saepe tenetur, odit velit ipsum beatae dolore illum accusantium alias ullam quas reiciendis! Quod at tenetur sint. Dolorum officia excepturi placeat, facere enim ullam, tempora accusantium culpa voluptates iusto non aperiam beatae ut laboriosam voluptatibus eum corrupti libero, laborum voluptas quasi at fugiat et vel? Eum.</p>
</main>
<footer class="main-footer active-element"><span class="copyright">©2018 A. James Liptak</span></footer>
</div>
*{
padding: 0; border: 0; margin: 0;
box-sizing: border-box;
list-style-type: none; /* Styled in normalize.css */
text-decoration: none;
color: #ccc;
}
body{
background-color: rgb(50, 101, 134);
}
.wrapper{
display: flex;
flex-direction: column;
height: 100vh;
margin: 0 auto;
max-width: 1550px;
padding-top: .5rem;
width: 93%;
}
.main-header a{
letter-spacing: .18rem;
text-transform: uppercase;
}
.masthead{
/* Both of these are needed to keep the #menu-toggle visible when nav list is active / open. */
position: relative;
z-index: 1000;
/********************************/
top: 0;
left: 0;
width: 100%;
align-items: baseline;
display: flex;
justify-content: space-between;
}
.masthead h1{
transition-delay: 450ms;
}
.menu-toggle{
cursor: pointer;
width: 55px;
z-index: 3;
}
.menu-toggle div{
background-color: #ccc;
border-radius: 25px;
box-shadow: 0px 3px 13px rgba(0,0,0,.3);
height: 7px;
transition-duration: 250ms;
transition-timing-function: cubic-bezier(.13,.24,.35,1.64);
}
.menu-toggle .one,
.menu-toggle .two{
margin-bottom: 7px;
}
.main-contents{
flex: auto;
}
.main-contents h2{
letter-spacing: 1.5px;
margin-bottom: .6rem;
text-transform: uppercase;
}
.main-contents p{
font-size: 1.1rem;
letter-spacing: 1.7px;
line-height: 1.35;
color: #ccc;
transition-delay: 150ms;
transition-duration: 850ms;
}
/*** Just getting silly now ***************************/
.main-footer span{
/* color: #ccc; */
transition-delay: 150ms;
transition-duration: 1350ms;
}
/*********************************************/
.main-footer{
font-size: .9em;
letter-spacing: .18rem;
margin-bottom: 1.5rem;
margin-top: 4rem;
text-align: center;
text-transform: uppercase;
}
/************* Style and animate the nav overlay ***********************/
.main-nav-list::before,
.main-nav-list::after{
background-color:#b94071;
content:"";
position: absolute;
top: 0;
height: 100vh;
width: 0vw;
transition: all 100ms ease-in-out 300ms;
}
.main-nav-list::before{
left: 0;
}
.main-nav-list::after{
right: 0;
}
.main-nav-list ul{
position: absolute;
top: -30%;
left: 50%;
transform: translate(-50%,-50%);
transition-duration: 300ms;
transition-timing-function: ease-in-out;
z-index: 2000;
}
.main-nav-list a{
display: block;
font-size: 2rem;
letter-spacing: 3px;
margin-bottom: 15px;
opacity: 0;
text-align: center;
text-transform: uppercase;
transition-delay: 130ms;
}
.main-nav-list .mobile-hide{/** Hide the link when viewing site on mobile devices. **/
display: none;
}
/************* Style the nav elements when active. ***********************/
.masthead.active h1{
text-shadow: 0px 3px 3px rgba(0,0,0,.4);
}
.menu-toggle.active .one{
box-shadow: 0px 3px 13px rgba(0,0,0,.4);
transform: translate(0, 14px) rotate(45deg);
}
.menu-toggle.active .two{
background-color: transparent;
box-shadow: none;
transform: translateX(-55px);
}
.menu-toggle.active .three{
box-shadow: 0px 3px 13px rgba(0,0,0,.4);
transform: translate(0,-14px) rotate(-45deg);
}
.main-nav-list.active::before,
.main-nav-list.active::after{
width: 25vw;
/* transition-duration: 1000ms; */
}
.main-nav-list.active ul{
top: 50%;
transform: translate(-50%,-50%);
transition-delay: 560ms;
transition-duration: 240ms;
transition-timing-function: cubic-bezier(.1, .2, .3, 1.4);
}
.main-nav-list.active a{
transition-delay: 600ms;
opacity: 1;
}
/*** Just getting silly now ***************************/
.wrapper.active p{
color: rgb(50, 101, 134);
transition-delay: 150ms;
transition-duration: 350ms;
}
.main-footer.active span{
color: rgb(50, 101, 134);
transition-duration: 350ms;
}
var menuToggle = document.querySelector("#menu-toggle");
var activeElements = document.querySelectorAll(".active-element");
var toggledMenu = menuToggle.addEventListener("click", function(){
// forEach is not supported in IE11
// activeElements.forEach(function(e){
// e.classList.toggle("active");
// });
for(var activated = 0; activated < activeElements.length; activated++){
activeElements[activated].classList.toggle("active");
}
})
Also see: Tab Triggers