Pen Settings



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


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


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.


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.


                <header id="page-header">
  <div class="site-name">📜 Shadow Scrolls</div>
    <ul class="menu" role="list">
      <li><a href="#">Shop</a></li>
      <li><a href="#">Blog</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Contact</a></li>
  <div class="warning">
    <p>⚠️ Scroll-driven animations are not supported in this browser. Try this demo in Chrome 115+.</p>
  <p>Scroll down 👇</p>


                header {
  --shadow: hsla(0 0% 0% / 0.1) 0 0.5rem 1rem;
  position: sticky;
  top: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem clamp(1rem, 4vw, 2rem);
  background-color: white;

  /* Fall back to persistent shadow */
  box-shadow: var(--shadow);

/* Fade in shadow on scroll when supported */
@supports (animation-timeline: scroll()) {
  header {
    animation: scroll-shadow linear both;
    animation-timeline: scroll();
    animation-range: 0ex 5ex;

  @keyframes scroll-shadow {
    from {
      box-shadow: none;

    to {
      box-shadow: var(--shadow);

/* Other demo styles */

.site-name {
  font-weight: bold;

.menu {
  display: flex;
  gap: 1rem;

.menu a {
  color: inherit;
  text-decoration: none;

main {
  height: 300vh;
  margin-block-start: 5rem;
  text-align: center;

body {
  font-family: system-ui, sans-serif;

  /* Easing gradient: */
  background: linear-gradient(
    to bottom,
    hsl(0, 0%, 100%) 0%,
    hsl(219.19, 55.23%, 99.76%) 10.6%,
    hsl(219.13, 55.37%, 99.05%) 20%,
    hsl(219.05, 55.59%, 97.92%) 28.4%,
    hsl(218.92, 55.89%, 96.39%) 35.8%,
    hsl(218.76, 56.28%, 94.49%) 42.6%,
    hsl(218.55, 56.76%, 92.22%) 48.7%,
    hsl(218.29, 57.33%, 89.61%) 54.4%,
    hsl(217.96, 58%, 86.67%) 59.8%,
    hsl(217.56, 58.78%, 83.39%) 64.9%,
    hsl(217.06, 59.69%, 79.76%) 70.1%,
    hsl(216.42, 60.75%, 75.77%) 75.3%,
    hsl(215.6, 62%, 71.35%) 80.8%,
    hsl(214.5, 63.51%, 66.41%) 86.6%,
    hsl(212.9, 65.42%, 60.66%) 93%,
    hsl(210.18, 68.2%, 53.14%) 100%

/* Warning for unsupported browsers */
.warning {
  color: black;
  background: papayawhip;
  margin: 1rem auto;
  padding: 1rem;
  max-width: fit-content;

@supports (animation-timeline: scroll()) {
  .warning {
    display: none;



Updated demo using CSS scroll-driven animations instead of the Intersection Observer API. Created for the "Sticky Page Header Shadow on Scroll" article: