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.

            
              - var sections = ['home', 'about', 'blog', 'contact']

nav#nav
  button.nav-icon#nav-icon: span
  
  ul
    each item in sections
      li: a(href='#' + item)=item
    
each section in sections
  section(id=section)
    h2=section
    p Click on the hamburger menu icon to see the vertical popout menu. Scroll down to see how it adapts to the background color. The menu icon is created using pure CSS, and the color of the menu adapts to the background color of the page by setting mix-blend-mode to "difference". The toggle animation only needs a tiny bit of JavaScript. This demo was tested in the latest versions of Chrome, Firefox and Safari. It also works on mobile.
    
    p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis nunc tellus, tempor vitae elit ac, ornare aliquet elit. Vivamus ac tincidunt est, vehicula semper neque. Aliquam eu velit mi. Mauris vel lorem sollicitudin, sollicitudin sem vel, pulvinar risus. Pellentesque ac pulvinar erat, quis aliquet lectus. Integer diam odio, auctor non ullamcorper scelerisque, imperdiet non est. Sed vulputate porttitor lorem, sit amet feugiat tortor pretium tristique. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ultrices, lectus at ultricies tempus, massa lorem tincidunt urna, at porta nulla massa ac est. Aliquam commodo auctor tempus. In molestie nisl eget diam scelerisque, vel porta metus euismod. Praesent venenatis augue dignissim, vestibulum ex eget, vestibulum sem. In varius est leo. Nam id lobortis erat. Etiam et metus sit amet justo consectetur lacinia faucibus in elit. Aenean elit lorem, pellentesque sed pellentesque at, cursus eget felis.
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=EB+Garamond|Work+Sans:700)

$color-light: #fff
$color-dark: #111
$font-primary: 'Adobe Garamond Pro', 'EB Garamond', Garamond, Georgia, 'Times New Roman', serif
$font-secondary: 'Work Sans', 'Arial Black', Gadget, sans-serif

*
  box-sizing: border-box
  padding: 0
  margin: 0
  border: 0
  outline: 0
  -webkit-font-smoothing: antialiased

html
  font-size: 10px // rem reset

body
  background: $color-dark
  color: $color-light
  font: #{2.6rem}/1.55 $font-primary

section
  padding: 12.5%
  width: 100%

  &:nth-of-type(even)
    background: $color-light
    color: $color-dark

p
  margin-bottom: 2.5em
  
a
  color: inherit
  text-decoration: none
    
h2
  font: bold 2.8rem $font-secondary
  text-transform: uppercase
  letter-spacing: 5px
  margin-bottom: 2em
  
nav
  mix-blend-mode: difference
  z-index: 100

  ul
    position: fixed
    top: 60px
    right: 5px
    height: 100vh
    visibility: hidden
    pointer-events: none
    list-style: none
    width: 35px

    li
      font: bold 1.5rem $font-secondary
      text-transform: uppercase
      letter-spacing: 2px
      padding: 0.75em 0
      writing-mode: vertical-lr

  &.active ul
    visibility: visible
    pointer-events: initial
    transition-delay: 0.2s


// Inspired by: https://github.com/callmenick/Animating-Hamburger-Icons

.nav-icon
  appearance: none
  background: transparent
  cursor: pointer
  display: inline-block
  height: 35px
  position: fixed
  top: 15px
  right: 15px
  transition: background 0.3s
  width: 35px

  span
    position: absolute
    top: 15px
    left: 5px
    background: $color-light
    display: block
    height: 3px
    right: 5px
    transition: transform 0.3s

    &:before,
    &:after
      width: 100%
      height: 3px
      background: $color-light
      content: ''
      display: block
      left: 0
      position: absolute

    &:before
      top: -8px

    &:after
      bottom: -8px

  .active & span
    transform: rotate(90deg)
            
          
!
            
              var nav = document.getElementById('nav');
var navlinks = nav.getElementsByTagName('a');

function toggleNav() {
    (nav.classList.contains('active')) ? nav.classList.remove('active') : nav.classList.add('active');
  }

document.getElementById('nav-icon').addEventListener('click', function(e) {
    e.preventDefault();
    toggleNav();
});

for(var i = 0; i < navlinks.length; i++) {
    navlinks[i].addEventListener('click', function() {
      toggleNav();
  });
}
            
          
!
999px
🕑 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 ..................

Console