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

              
                <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="navigation__link navigation__link--is-active">Home</a></li>
        <li class="navigation__item"><a href="#" class="navigation__link">About Us</a></li>
        <li class="navigation__item"><a href="#" class="navigation__link">Work</a></li>
        <li class="navigation__item"><a href="#" class="navigation__link">Clients</a></li>
        <li class="navigation__item"><a href="#" class="navigation__link">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>
              
            
!

CSS

              
                @use postcss-preset-env {
  stage: 0;
}

/* helpers/grid.css */

.grid {
  inline-size: 90%;
  margin-inline: auto;
  max-inline-size: 48em;
}

/* helpers/sticky.css */

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

.sticky--top {
  top: 0;
}

/* layout/base.css */

* {
  box-sizing: inherit;
}

html {
  box-sizing: border-box;
}

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

/* layout/header.css */

.header {
  background-color: #fff;
  padding-block: 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-block: 6em;
}

/* modules/headline.css */

h1 {
  margin-block: 0 0.5em;
}

/* modules/navigation.css */

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

.navigation__list--inline {
  display: flex;
  gap: 1.5em;
}

.navigation__link {
  color: inherit;
  display: block;
  padding-inline: 1em;
  text-decoration: none;
}

.navigation__link--is-active {
  background-color: #000;
  border-radius: 999em;
  color: #fff;
}

/* modules/paragraph.css */

p {
  padding-block: 1.5em;
}
              
            
!

JS

              
                import throttle from "https://cdn.skypack.dev/lodash@4/throttle";

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, 300));

              
            
!
999px

Console