cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <header class="header sticky sticky--top js-header">

  <div class="grid">

    <nav class="navigation">
      <ul class="navigation__list navigation__list--inline">
        <li class="navigation__item"><a href="#" class="is-active">Home</a></li>
        <li class="navigation__item"><a href="#">About Us</a></li>
        <li class="navigation__item"><a href="#">Work</a></li>
        <li class="navigation__item"><a href="#">Clients</a></li>
        <li class="navigation__item"><a href="#">Contact</a></li>
      </ul>
    </nav>

  </div>

</header>

<main class="main">

  <div class="grid">

    <h1>Lorem ipsum dolor sit.</h1>

    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Id sed voluptatem error vel eius placeat harum voluptate doloribus ratione in, vero aliquid et, itaque, repellat magnam nisi adipisci unde, odit esse architecto hic! Eaque libero officia laudantium laboriosam non velit vero pariatur, rem nisi commodi dolores, culpa quibusdam dolorem nemo voluptatem. Ipsam, molestias autem iste est quia magni iusto distinctio esse magnam possimus tenetur dolor, suscipit fugiat ad? Natus officia magnam ipsam. Nisi aut quis natus voluptatum, sapiente inventore quidem similique odio, quod iste delectus commodi maxime asperiores doloribus officiis fuga, eaque, beatae ipsam assumenda architecto. At minima pariatur qui!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatem numquam sint nisi natus fugiat quibusdam, iusto unde tenetur consequuntur, dolorum laborum consectetur explicabo at blanditiis aperiam perferendis totam neque vitae eos quisquam, ratione cum id fuga? Ad harum dolores optio debitis, eaque excepturi, iste totam. Quasi, maiores eligendi laudantium nobis harum ullam nihil voluptas officia id molestiae animi deleniti placeat dolorum atque fuga. Mollitia ducimus corporis natus doloribus blanditiis, voluptatem officia nesciunt sit dolorem incidunt illum vel voluptas, exercitationem nemo repellendus deleniti! Vero rerum natus blanditiis voluptatibus nihil deserunt, vitae nulla reprehenderit perferendis praesentium minus, dolor consequuntur repellat repudiandae, facilis veritatis dolorem? Nisi magni dolor, ut maiores voluptas rem amet commodi est distinctio perferendis mollitia dicta dolores, officiis dignissimos dolorem ea soluta ex quae nemo. Cupiditate ab ratione voluptatem non impedit, tempora voluptas ipsam iste sed a, animi sunt veniam deserunt molestias nobis excepturi. Earum inventore vitae recusandae, sint. Aut.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nemo magni maxime rerum minus impedit autem explicabo ex eius perspiciatis libero ipsam ab harum maiores rem aliquid inventore, dolor optio quas, temporibus, deleniti soluta expedita similique. Aperiam ad quasi sed officia dolorem, consectetur ipsum, vel possimus fugiat expedita adipisci, porro ea inventore accusantium, blanditiis nam minus. Laudantium similique amet et odio culpa quibusdam vel doloremque voluptatem totam a sit blanditiis placeat, beatae quasi esse dicta, earum alias delectus hic libero magni ipsam eveniet tempore. Inventore vitae error, provident ipsum quidem atque, tempora laboriosam at totam unde illo eligendi magnam reiciendis nam magni ut, laudantium deserunt odio voluptatibus maiores facilis. Voluptas ea consectetur, totam non possimus laudantium at quibusdam nihil doloribus, porro ipsum qui animi itaque velit.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nulla adipisci a vero sint ducimus provident quas, eveniet tenetur, corporis ex quidem aliquam consequatur quam dicta dolores modi nisi dolorem magnam, consequuntur quasi assumenda saepe similique eos accusantium, odio! Excepturi illo corporis, magni eaque animi esse, odit minima expedita facilis repellendus, culpa magnam eius delectus consequatur tenetur. Totam magnam voluptate mollitia quod omnis, hic, labore, veniam molestiae amet, quam distinctio optio nobis tenetur similique blanditiis. Fugiat obcaecati repudiandae culpa totam quasi perspiciatis rerum quibusdam architecto asperiores, enim quisquam error numquam officiis, voluptatibus debitis vitae sint. Neque ipsam, nobis sunt ut consectetur. Doloremque velit quasi necessitatibus inventore earum rem enim omnis aut doloribus laboriosam accusamus consequatur libero facere vitae dolorem mollitia voluptates molestias fugiat laborum dignissimos esse, nesciunt totam, blanditiis accusantium! Provident perspiciatis deserunt nostrum. Et provident optio enim perspiciatis tenetur distinctio officia, molestias in repellendus eius quis tempora animi. Reprehenderit, veniam.</p>

  </div>

</main>
            
          
!
            
              @use postcss-cssnext; 

/* helpers/grid.css */

.grid {
  margin-left: auto;
  margin-right: auto;
  max-width: 48em;
  width: 90%;
}

/* helpers/sticky.css */

.sticky {
  position: sticky;
  will-change: transform;
}

.sticky--top {
  top: 0;
}

/* layout/base.css */

* {
  box-sizing: inherit;
}

html {
  box-sizing: border-box;
  height: 100%;
}

body {
  font-family: 'Roboto', sans-serif;
  line-height: 1.75;
  margin: 0;
  min-height: 100%;
}

/* layout/header.css */

.header {
  background-color: #fff;
  padding-bottom: 1em;
  padding-top: 1em;
}


.header::after {
  bottom: 0;
  box-shadow: 0 0.0625em 0.5em rgba(0, 0, 0, 0.3);
  content: '';
  left: 0;
  opacity: 0;
  position: absolute;
  right: 0;
  top: 0;
  transition: opacity 0.3s;
  z-index: -1;
}

.header.is-active::after {
  opacity: 1;
}

/* layout/main.css */

.main {
  padding-top: 6em;
  padding-bottom: 6em;
}

/* modules/headline.css */

h1 {
  margin-bottom: 1.5em;
  margin-top: 0;
}

/* modules/navigation.css */

.navigation a {
  color: inherit;
  display: block;
  text-decoration: none;
}

.navigation .is-active {
  background-color: #000;
  color: #fff;
  padding-left: 1em;
  padding-right: 1em;
  border-radius: 999px;
}

.navigation__list {
  list-style: none;
  margin: -0.5em;
  padding: 0;
}

.navigation__list--inline {
  display: flex;
}

.navigation__item {
  margin: 0.5em;
}

/* modules/paragraph.css */

p {
  margin-bottom: 1.5em;
  margin-top: 1.5em;
}
            
          
!
            
              function throttle(fn, delay) {
  let last;
  let timer;

  return () => {
    const now = +new Date;

    if (last && now < last + delay) {
      clearTimeout(timer);

      timer = setTimeout(() => {
        last = now;
        fn();
      }, delay);
    } else {
      last = now;
      fn();
    }

  };
}

function onScroll() {
  if (window.pageYOffset) {
    $$header.classList.add('is-active');
  } else {
    $$header.classList.remove('is-active');
  }
}

const $$header = document.querySelector('.js-header');

window.addEventListener('scroll', throttle(onScroll, 25));

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console