css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <a href="#" class="toggle-navigation">Toggle Navigation</a>
        <nav role="navigation" class="">
            <div class="nav-links">
                <a href="#">Navigation Link 1</a>
                <a href="#">Navigation Link 2</a>
                <a href="#">Navigation Link 3</a>
                <a href="#">Navigation Link 4</a>
                <a href="#">Navigation Link 5</a>
                <a href="#">Navigation Link 6</a>
                <a href="#">Navigation Link 7</a>
                <a href="#">Navigation Link 8</a>
                <a href="#">Navigation Link 9</a>
                <a href="#">Navigation Link 10</a>
                <a href="#">Navigation Link 11</a>
                <a href="#">Navigation Link 12</a>
        <section id="content" role="main">
            <h1>Responsive Navigation</h1>
            <p class="teaser">This responsive nav scales irrespective of how many links you place in it and it doesn't use JavaScript to measure the menu's height. (JS is only used to toggle a class on the nav element to say whether it is visible or not). The animations in it are hardware accelerated on mobile phones. It doesn't leave a gap at the bottom of the document in the way that moving the whole page with translateY does. If you see a strange flash of white when toggling the navigation, that disappears when viewing the demo not inside of Codepen's iframe...</p>
          <p>The technique is simple. It uses two block elements (I used a <code>&lt;div&gt;</code> inside a <code>&lt;nav&gt;</code> but it could just as easily have been a <code>&lt;ul&gt;</code> inside a <code>&lt;div&gt;</code> or whatever). CSS 3 transforms are used on the inner element to slide it up and down, as transforms will be hardware accelerated - this is mostly important for mobile. Use <code>overflow: hidden</code> on the outer element so that the inner one won't be visible when it's shifted up. The <code>max-height</code> of the outer element is toggled between <code>0px</code> and <code>9999px</code>. This happens faster than the animation on slide down, and slower on slide up, so the animation is visible on both occasions.</p>

          <p>I'd prefer it if the content would slide down instead of toggling, so if you figure out a way to make that happen, be sure to let me know! Get in touch on Twitter <a href='https://twitter.com/adrianosmond'>@adrianosmond</a>. A full explanation about to why I needed to do this can be found <a href='http://adrianosmond.com/experimenting-with-responsive-navigations/'>here</a>. </p>

            <p>Aliquam pulvinar laoreet risus. Sed malesuada condimentum auctor. Nullam porta, velit at sodales ultricies, lacus erat imperdiet tellus, porttitor eleifend ipsum quam nec ante. Nunc vitae neque quis augue accumsan posuere sit amet non odio. Morbi gravida iaculis lorem, non pharetra eros auctor eget. Pellentesque tellus mauris, facilisis quis consequat tincidunt, mollis vitae augue. Donec nec risus lobortis libero rhoncus ultricies eget sed nisl.</p>

            <p>Donec varius lectus vel velit tempor imperdiet. Pellentesque sodales aliquet odio, non porttitor dolor vulputate nec. Ut malesuada, neque sit amet semper molestie, massa neque ultricies odio, id euismod libero nulla ac enim. Suspendisse potenti. Ut sem elit, congue non mattis sit amet, ullamcorper venenatis orci. Nunc in gravida purus. Ut vel tempor nunc. Etiam sed mollis ipsum. Nunc facilisis diam sed mi porttitor interdum. Morbi malesuada lectus id massa consectetur adipiscing. Proin hendrerit augue eget mi pharetra sed rutrum nulla mattis. In eleifend enim molestie erat fermentum euismod. Donec a vulputate augue. In hac habitasse platea dictumst. Nunc congue, felis non auctor pellentesque, sem augue suscipit elit, sollicitudin scelerisque libero erat eget diam.</p>

            <p>Mauris a ligula at mauris feugiat accumsan ornare a velit. Pellentesque porttitor, urna eget sollicitudin cursus, urna elit auctor augue, non dictum tellus leo non dolor. Aenean vestibulum, dui faucibus placerat mollis, metus ante viverra risus, ut scelerisque lacus lectus id purus. Cras viverra risus nec quam tempor viverra. Vivamus accumsan aliquet sodales. Pellentesque orci urna, vehicula ut lacinia at, semper in urna. Suspendisse turpis erat, venenatis nec mollis nec, placerat ut metus. Vivamus ut orci lorem. Curabitur mollis tincidunt congue. Ut interdum felis a neque tristique bibendum. Sed vitae urna nisl, eget tincidunt est. Cras felis purus, pulvinar quis hendrerit non, sollicitudin vel metus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Ut elementum fermentum tortor, non feugiat lorem tempor consequat.</p>
        <footer role="contentinfo">
            <p><a href="http://adrianosmond.com">Made by Adrian Osmond, 2013.</a></p>
              @import "compass/css3";

* {
  box-sizing: border-box;
  -moz-box-sizing: border-box;

body {
  padding: 1em;
  font-size: 16px;
  font-family: Arial, sans-serif;
  line-height: 150%;
  background-color: #bd7e13;
  color: #fff;
  min-width: 230px;
  -webkit-text-size-adjust: none

h1 {
  font-size: 36px;
  font-weight: bold;
  font-family: 'Roboto Slab', serif;
  margin-bottom: 1em;
  line-height: 1em;

a, a:visited {
  color: #fff;
  text-decoration: none;

a:hover {
  text-decoration: underline;

p {
  margin-bottom: 1em;

p a, 
p a:visited {
  text-shadow: 1px 1px 1px #000;
  text-decoration: underline;
  font-weight: bold;

code {
  font-family: "Courier New", Courier, monospace;
  border: 1px dashed rgba(0,0,0,0.2);
  background-color: rgba(0,0,0,0.1);

.teaser {
  font-size: 20px;
  font-style: italic;

.toggle-navigation {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 48px;
  padding: 1em 1em 0.5em 4em;
  display: block;
  margin-bottom: 1em;
  background-color: #bd7e13;
  z-index: 1;
  &:before {
    content: "";
    width: 30px;
    height: 29px;
    top: 13px;
    left: 20px;
    background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAdCAYAAAC9pNwMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGhJREFUeNpi/P//P8NAACaGAQKjFo9aTF+Lz115+P/vv39UwSCzsNnBiC0ff/v+6/+/f/+o4zMmJgYuTjZGonx86vxtBpDF1MAgs4j28WiqHk3Vo6l6NFWPpurRVD2aqkctHp4WAwQYAJKzxP4CVkO8AAAAAElFTkSuQmCC);

nav {
  margin: 2em 0 1em;
  overflow: hidden;
  max-height: 0;
  font-style: italic;
  -webkit-transition: max-height 0.3s ease-in;
  -moz-transition: max-height 0.3s ease-in;
  -ms-transition: max-height 0.3s ease-in;
  -o-transition: max-height 0.3s ease-in;
  transition: max-height 0.3s ease-in;
  a {
    display: block;
    padding: 5px;
  &.visible {
    max-height: 9999px;
    .nav-links {
      -webkit-transform: translateY(0%);
      -moz-transform: translateY(0%);
      -ms-transform: translateY(0%);
      -o-transform: translateY(0%);
      transform: translateY(0%);

.nav-links {
  -webkit-transition: -webkit-transform 0.3s ease-in;
  -moz-transition: -moz-transform 0.3s ease-in;
  -ms-transition: -ms-transform 0.3s ease-in;
  -o-transition: -o-transform 0.3s ease-in;
  transition: transform 0.3s ease-in;
  -webkit-transform: translateY(-100%);
  -moz-transform: translateY(-100%);
  -ms-transform: translateY(-100%);
  -o-transform: translateY(-100%);
  transform: translateY(-100%);
  background-color: #a86707;
  padding: 0 10px;
  &:after {
    content: "";
    display: table;
    clear: both;

@media screen and (min-width: 25em) {
  nav a {
    float: left;
    width: 47.5%;

@media screen and (min-width: 40em) {
  nav a {
    float: left;
    width: 32%;

              //new FastClick(document.body);

var nav = $("nav");

$(".toggle-navigation").click(function() {
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................