Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ 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

Auto Save

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

              
                <!-- do we really need to bother with IE9 now? -->
<!--[if lte IE 9]>
<style>
ul.text-slide a:after{display:none}
ul.text-slide a:hover{
	top:-25px;
	background:#eee;color:#444;
}
ul.text-slide a:hover b{color:#444}
</style>
<![endif]-->

<body id="bodytop">
  <div id="toggle" class="hamburger"> <a class="menu-open" href="#toggle"> <span class="toggle"><i>Menu open</i></span> </a> <a class="menu-close" href="#bodytop" id="toggle2"> <span class="toggle"><i>Menu Close</i></span> </a> </div>
  <div class="wrap">
    <header class="header">
      <h1>My&nbsp;Logo/Name</h1>
      <nav class="main-nav">
        <ul class="text-slide">
          <!-- the nested  'b' element is just used for the text-slide effect and not needed for the centering demo -->
          <li><a href="#"><b>Link 1</b></a></li>
          <li><a href="#"><b>Link 2</b></a></li>
          <li><a href="#"><b>Link 3</b></a></li>
          <li><a href="#"><b>Link 4</b></a></li>
          <li><a href="#"><b>Link 5</b></a></li>
          <li><a href="#"><b>Link 6</b></a></li>
          <li><a href="#"><b>Link 7</b></a></li>
        </ul>
      </nav>
      <p class="sign-reg"><a class="sign-in" href="#">Sign In</a> <a class="register" href="#">Register</a></p>
    </header>
    <main class="main">
      <h2>Main content here</h2>
      <p>The main nav links above will remain centred in the viewport even though the logo and sign-in links are uneven lengths. The main caveat is that the nav links will not be allowed to wrap as white-space:nowrap is used to force them onto one line.
        Therefore you will need to use a media query to change the behaviour at about 860px or whatever your layout requires.</p>
    </main>
    <footer class="footer">
      <h3>Footer content here</h3>
    </footer>
  </div>
</body>
              
            
!

CSS

              
                html {
  box-sizing: border-box;
}
*,
*:before,
*:after {
  box-sizing: inherit;
}
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}
.wrap {
  background: #f9f9f9;
  max-width: 1170px;
  margin: auto;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.header {
  display: flex;
  padding: 10px;
  background: #eee;
  align-items: center;
  border-bottom: 2px solid #000;
}
.header h1 {
  margin: 0;
  padding: 0 10px 0 0;
}
.main-nav {
  flex: 1 0 0%;
  white-space: nowrap;
  transition: 0.5s ease;
}
.header h1,
.sign-reg {
  flex-basis: 50%;
}
.main-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
}
.main-nav a {
  display: block;
  padding: 10px;
  color: #fff;
  background: #000;
  text-decoration: none;
  border: 1px solid #fff;
}
/* code below just for a sliding effect on the nav links and is not needed for main demo */
ul.text-slide {
  height: 2rem;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.8rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
ul.text-slide li {
  border: 1px solid #444444;
  border-right: 1px solid #fff;
  height: 2rem;
  overflow: hidden;
}
ul.text-slide li:last-child {
  border-right: 1px solid #444;
}
ul.text-slide a {
  padding: 0;
  border: none;
  position: relative;
  top: -2rem;
  padding-top: 2rem;
  text-decoration: none;
  background: #444;
  -moz-transition: top 0.2s linear;
  -webkit-transition: top 0.2s linear;
  transition: top 0.2s linear;
}
ul.text-slide a:after {
  content: " ";
  background: #eee;
  position: absolute;
  top: 0px;
  left: 0;
  right: 0;
  height: 2rem;
  z-index: 2;
}
ul.text-slide a:hover {
  top: 0;
}
ul.text-slide a b {
  outline: none;
  padding: 0 15px;
  display: block;
  position: relative;
  z-index: 3;
  font-weight: normal;
  text-shadow: 0 -2rem 0px #444;
  color: #fff;
  height: 2rem;
  line-height: 2rem;
}
/* end text effect code */
p.sign-reg {
  margin: 0;
  padding: 0 0 0 10px;
  display: flex;
  justify-content: flex-end;
}
.sign-reg a {
  padding: 10px;
  white-space: nowrap;
}
.main {
  background: #ccc;
  padding: 10px;
  flex: 1 0 0%; /* remove this if you don't want main's background to reach footer*/
}
.footer {
  background: #000;
  padding: 10px;
  color: #fff;
  margin-top: auto;
}
.hamburger {
  display: none;
}
/* media queries for smaller display */

@media screen and (max-width: 860px) {
  .wrap {
    margin: 0;
  }
  .header {
    padding-left: 40px;
  }
  .header h1 {
    padding-left: 10px;
  }
  .main-nav {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    z-index: 999;
    background: rgba(255, 255, 255, 0.9);
    overflow: auto;
    flex-wrap: wrap;
    transform: translateX(-100%);
  }
  .main-nav ul {
    height: auto;
    flex-wrap: wrap;
  }
  .main-nav li {
    flex: 1 0 100%;
  }
  /* hamburger styles */
  .hamburger {
    position: fixed;
    display: block;
    left: 10px;
    top: 15px;
    z-index: 1000;
    transition: 0.5s ease;
    width: 35px;
    height: 35px;
    background:blueviolet;
    transition-delay: 0.5s;
  }
  .hamburger a {
    background: transparent;
    color: transparent;
    position: absolute;
    top: 0;
    left: 1px;
    width: 32px;
    height: 35px;
    overflow: hidden;
  }
  /* hamburger menu */
  .toggle {
    position: absolute;
    top: 7px;
    left: 3px;
    background: transparent;
    padding: 0;
    margin: 0;
    cursor: pointer;
    outline: none;
    width: 26px;
    height: 21px;
    border: none;
    border-top: 3px solid #fff;
    border-bottom: 3px solid #fff;
    text-decoration: none;
    color: #ccc;
    outline: 0;
  }
  .toggle i {
    opacity: 0;
  }
  .toggle:before,
  .toggle:after {
    content: "";
    display: block;
    width: 26px;
    height: 3px;
    top: 6px;
    left: 0;
    background: #fff;
    position: absolute;
  }
  .toggle,
  .toggle:before,
  .toggle:after {
    transition: all 0.3s ease;
    transform: rotate(0deg);
  }
  .hamburger:target .toggle {
    border-color: transparent;
  }
  .hamburger:target .toggle:before {
    transform: rotate(45deg);
  }
  .hamburger:target .toggle:after {
    transform: rotate(-45deg);
  }
  .menu-close {
    z-index: -1;
  }
  .hamburger:target .menu-open {
    opacity: 0;
  }
  .hamburger:target .menu-close {
    z-index: 2;
  }
  /* nav styles open */
  .main-nav {
    padding-top: 45px;
  }
  .main-nav li,
  .main-nav li a {
    background: transparent;
    border: none;
  }
  ul.text-slide {
    height: auto;
    font-size: 1.5rem;
  }
  ul.text-slide li {
    border: none;
  }
  .hamburger:target + .wrap .main-nav {
    transform: translateX(0);
    background: rgba(255, 255, 255, 1);
    transition-delay: 1s;
  }
  .hamburger:target {
    left: 92%;
    transition-delay: 0.5s;
  }
  .hamburger:target + .wrap .main-nav a,
  .hamburger:target + .wrap ul.text-slide li {
    border-bottom: 1px solid #000;
  }
  ul.text-slide {
    height: auto;
  }
  ul.text-slide li {
    border: none;
    border-bottom: 1px solid #000;
    height: 3rem;
  }
  ul.text-slide li:last-child {
    border-right: none;
  }
  ul.text-slide a {
    top: -3rem;
    padding-top: 3rem;
    font-size: 1.5rem;
    color:#000;
  }
  ul.text-slide a:after {
    height: 3rem;
  }
  ul.text-slide a b {
    text-shadow: 0 -3rem 0px #444;
    height: 3rem;
    line-height: 3rem;
    color:#000;
  }
  /* end text effect code */
}

@media screen and (max-width: 480px) {
  h1 {
    font-size: 1rem;
  }
}

              
            
!

JS

              
                //nope
              
            
!
999px

Console