Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

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.

+ add another resource

Packages

Add Packages

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.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="container">
<header>
  <h1><a href="#"><span>Blackout</span> God</a></h1>
<nav id="headernav">
  <a href="#">Home</a>
  <a href="#">Products</a>
  <a href="#">Order</a>	
  <a href="#"><span>Legal</span> Disclaimer</a></nav>	
</header>

<main>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/blackout-can.png" style="width:20%; height: auto; float: left; margin-right: 5%; margin-top: 4rem;">
	<p><b>Blackout God</b> is the ultimate energy drink. It will hit you on the head with a Rickenbacker 4001 electric bass guitar. It will make you see through portals. It will spaghettify your body into a wet noodle, then juice you with the power of a thousand suns.
<p>We’ve achieved this by styling our drink with a unique combination of stimulants and psychoactive substances:
<h2>Ingredients</h2>
<ul>
	<li>25mg Caffeine
	<li>35mg Sugar
	<li>15mg Taurine
	<li>22mg Ayahuasca
	<li>15mg Salvia divinorum
	<li>50mg Piper methysticum
	<li>12mg Artemisia absinthium
	<li>Ipomoea tricolor
</ul>
<p>Blackout God is available from your local retailer. Look for the specially marked cryogenically sealed delivery mechanism.
</main>
</div>
              
            
!

CSS

              
                * { box-sizing: border-box; }
body { 
  margin: 0;
  font-family: Brandon-Grotesque, sans-serif; 
  color: #fff;
  background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/hexgrid.svg), linear-gradient(#111 0%,#111 50%, #555 100%); 
  background-size: 35.5px 25px, 100% 100%; 
  background-blend-mode: exclusion;
}
header { 
  display: flex; 
  align-items: center;
  text-transform: uppercase;  
  background: rgba(0,0,0,0.2);
}
#headernav a { 
  text-transform: uppercase;
  color: #fff;
  transition: .3s;
  text-decoration: none;
  padding: .6rem 1rem; 
}
header h1 a > span { 
  background: #fff; 
  color: #000;
  padding: 0 1rem;
  display: inline-block;
  margin-right: .5rem;
}
header nav { 
  margin-left: 7%; 
}
header h1 { 
  margin: 0;
}
header h1 a {
 text-decoration: none; 
  color: #fff;
}
#headernav a { -webkit-transition: .3s; }
#headernav a:hover { background: #000; }

main { 
  background: rgba(0,0,0,0.3);
  width: 60%; padding: 1rem;
  margin-left: 20%; 
  font-size: 1.1rem;
  margin-top: 2rem; 
  margin-bottom: 1rem;
}
main ul { margin-left: 25%; }

@media all and (max-width: 850px) {
main {  
  width: 100%; margin: 0;
}
#headernav {
  position: absolute;
  right: -20%;
  top: 0;
  width: 20%;
  background: #000;
  height: 100%;
  -webkit-transition: .3s;
}
#headernav a { display: block; }
#headernav a:hover { background: #ccc; color: #000; }
#headernav a span { display: none; }

#headernav.slider { right: 0; }
header button { margin-left: 2rem; }
}

              
            
!

JS

              
                var headernav = document.getElementById("headernav"),
container = document.getElementById("container"),
tablet = window.matchMedia("screen and (max-width: 850px)"),
header = document.getElementsByTagName("header")[0],
menulink = document.createElement("button");
menulink.id = "menulink";
menulink.innerHTML = "MENU";

function switcheroo(state) {
if (tablet.matches) {
    headernav.remove();
    header.appendChild(menulink);
    container.appendChild(headernav);
  } else {
	menulink.remove();
	header.appendChild(headernav);
  }
}

switcheroo(tablet);
tablet.addListener(switcheroo);

menulink.addEventListener("click", function() {
	headernav.classList.toggle("slider");
})

              
            
!
999px

Console