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

              
                <div class="site">
  <header>
    <nav>
      <ul role="list">
        <li>
          <a href="#first">First</a>
        </li>
        <li>
          <a href="#second">Second</a>
        </li>
        <li>
          <a href="#third">Third</a>
        </li>
        <li>
          <a href="#slider">Slider</a>
        </li>
        <li>
          <a href="#overflow">Overflow</a>
        </li>
      </ul>
    </nav>
  </header>

  <main>
    <section id="first">
      This is the first section. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum enim laborum aliquam quos beatae? Reprehenderit quibusdam sapiente mollitia nostrum sed consectetur, asperiores eveniet magnam quae quisquam quidem voluptas eligendi nam officiis harum vero maiores ab soluta iste. Id impedit, inventore dolor, totam esse eum, repudiandae dignissimos amet quo possimus ex. Lorem ipsum dolor sit amet consectetur adipisicing elit. Minus provident perspiciatis accusamus vel consequuntur doloribus, fugiat laudantium incidunt consequatur ipsam suscipit aliquid in culpa neque quae tenetur. Modi, labore autem!
    </section>
    <section id="second">
      This is the second section. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum enim laborum aliquam quos beatae? Reprehenderit quibusdam sapiente mollitia nostrum sed consectetur, asperiores eveniet magnam quae quisquam quidem voluptas eligendi nam officiis harum vero maiores ab soluta iste. Id impedit, inventore dolor, totam esse eum, repudiandae dignissimos amet quo possimus ex. Lorem ipsum dolor sit amet consectetur adipisicing elit. Excepturi possimus reiciendis quaerat, architecto culpa debitis molestiae numquam sequi deleniti qui corporis doloribus quibusdam ut pariatur magnam illo voluptatum vitae rerum natus aspernatur ab iste tempora! Corporis ipsa quam necessitatibus esse.
    </section>
    <section id="third">
      This is the third section. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum enim laborum aliquam quos beatae? Reprehenderit quibusdam sapiente mollitia nostrum sed consectetur, asperiores eveniet magnam quae quisquam quidem voluptas eligendi nam officiis harum vero maiores ab soluta iste. Id impedit, inventore dolor, totam esse eum, repudiandae dignissimos amet quo possimus ex. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit possimus assumenda quo praesentium dolorem esse asperiores rerum quod error quasi, sit ex accusantium architecto quaerat excepturi impedit repellat porro, culpa numquam est aut. Aut unde perferendis temporibus officiis possimus nobis reprehenderit rerum similique illum architecto?
    </section>

    <section id="slider">
      <figure>
        <img src='https://images.unsplash.com/photo-1631466266525-53e979c9e29b?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYzMjg1NDI4NQ&ixlib=rb-1.2.1&q=80&w=800' alt=''>
        <figcaption>
          <h1>This is a caption</h1>
        </figcaption>
      </figure>
      <figure>
        <img src='https://images.unsplash.com/photo-1630241040421-f777fdbc7c8e?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYzMjg1NDI3Nw&ixlib=rb-1.2.1&q=80&w=800' alt=''>
        <figcaption>
          <h1>This is a caption</h1>
        </figcaption>
      </figure>
      <figure>
        <img src='https://images.unsplash.com/photo-1631931020352-da7c5165e715?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYzMjg1NDI2Mg&ixlib=rb-1.2.1&q=80&w=800' alt=''>
        <figcaption>
          <h1>This is a caption</h1>
        </figcaption>
      </figure>
      <figure>
        <img src='https://images.unsplash.com/photo-1631168056607-dcb48cb3b63d?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTYzMjg1NDI1NA&ixlib=rb-1.2.1&q=80&w=800' alt=''>
        <figcaption>
          <h1>This is a caption</h1>
        </figcaption>
      </figure>
    </section>
    
    <section id="overflow">
      <div class="overflow">
        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit maiores eius quidem labore magni temporibus fugiat repudiandae in ipsa voluptates aliquid debitis nesciunt sed itaque architecto, iste odio tenetur deserunt quam quas velit ipsum delectus accusantium. Natus totam tempora labore, eveniet consectetur veniam sequi illo numquam quas fugit, et in, explicabo itaque velit nesciunt adipisci ea omnis! Id debitis repellendus recusandae exercitationem aperiam ad ducimus. Reiciendis dolorem consequatur distinctio repudiandae voluptates, necessitatibus, esse autem consectetur quibusdam earum vero ipsa corporis. Lorem, ipsum dolor sit amet consectetur adipisicing elit. Sapiente quas dolores aspernatur debitis libero voluptatem quae, atque dicta ratione laborum quaerat! Nostrum eligendi facere totam doloribus dolore dolorum, distinctio veritatis quidem blanditiis iusto earum, aliquam nemo. Nisi eveniet facilis odit deserunt dolore, sapiente velit! Deserunt, odit quos doloribus eligendi suscipit ipsam repellendus voluptatem maiores deleniti obcaecati, consequuntur doloremque magni repellat neque nulla? Nulla dignissimos repellendus odit accusantium, deleniti beatae temporibus!
      </div>
    </section>

  </main>
</div>

<!--<div id="mark"></div>-->
              
            
!

CSS

              
                html {
  --timing: .2s;
  scroll-behavior: smooth;
  scroll-padding-top: 60px;
}

body {
  //overscroll-behavior: none;
}

.site {
  display: grid;
  grid:
    auto /
    minmax(1em, 1fr)
    minmax(0, 600px)
    minmax(1em, 1fr);
  margin: 5rem auto;
}

main {
  padding-bottom: 80vh;
}

header {
  margin-bottom: 5rem;
  position: sticky;
  top: -1px;
  z-index: 10;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.0001),
    0 10px 10px -5px rgba(0, 0, 0, 0.0001);
}

nav {
  background: #24b47e;
  overflow-x: auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
  @media (max-width: 420px) {
    background-image: 
	
    /* Shadows */ 
    linear-gradient(to right, #24b47e, #24b47e),
    linear-gradient(to right, #24b47e, #24b47e),
  
/* Shadow covers */ 
    linear-gradient(to right, rgba(0,0,0,.2), rgba(255,255,255,0)),
    linear-gradient(to left, rgba(0,0,0,.2), rgba(255,255,255,0));   

  background-position: left center, right center, left center, right center;
	background-repeat: no-repeat;
	background-color: #24b47e;
	background-size: 20px 100%, 20px 100%, 10px 100%, 10px 100%;
	
	/* Opera doesn't support this in the shorthand */
	background-attachment: local, local, scroll, scroll;
  }
}

nav::-webkit-scrollbar {
  display: none;
}

nav ul {
  display: flex;
  justify-content: space-evenly;
  text-align: center;
  flex-wrap: nowrap;
  @media (max-width: 420px) {
    justify-content: flex-start;
  }
}

nav a {
  color: #fff !important;
  padding: 1rem;
  display: inline-block;
  font-weight: 700;
}

section + section {
  margin-top: 3rem;
}


/* Slider */
#slider {
  width: 100%;
  overflow-x: auto;
  display: grid;
  grid: 400px / auto-flow 90%;
  gap: 10px;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  padding-bottom: 1em;
  perspective: 2px;
  transform-style: preserve-3d;
}

figure {
  display: grid;
  place-items: end center;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  overflow: hidden;
  background: #000;
  transform-style: preserve-3d;
}

img {
  height: 100%;
  width: 100%;
  object-fit: cover;
  transform: translateZ(-1px) scale(1.6);
  opacity: 0.5;
  will-change: transform;
}

img,
figcaption {
  grid-area: 1 / 1;
}

figcaption {
  padding: 2rem;
  z-index: 1;
}

h1 {
  font-size: 3rem;
  color: #fff;
}



/* Overflow */
.overflow {
  height: 300px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 2rem;
  background: #73e4a2;
  border-radius: 4px;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
  color: #005450;
}


#mark {
  position: absolute;
  width: 1px;
  height: 1px;
  top: calc(var(--top) * 1px);
  left: 0;
}


html,
body {
  height: 100%;
  background: #f2f7f1;
}





/* Header effect */
.site > :not(header) {
  grid-column: 2 / -2;
}

header {
  display: grid;
  grid: inherit;
  grid-column: 1 / -1;
}

header > * {
  grid-column: 2 / -2;
}

header:before,
header:after {
  content: '';
  background: #24b47e;
  transform: scaleX(var(--resize, 0));
  transition: var(--timing) cubic-bezier(.5, 0, .5, 1);
  z-index: -1;
}
header:before {
  grid-column-start: 1;
  transform-origin: right;
}
header:after {
  grid-column-start: 3;
  transform-origin: left;
}

/*.resize-box header:before,
.resize-box header:after {
  --resize: 1;
}*/

.resize-box::before,
.resize-box::after {
  --resize: 1;
}

header {
  transition: calc(var(--timing) * .25) box-shadow;
}

/*.resize-box header {
  transition: calc(var(--timing) * 1.25) calc(var(--timing) * .25) box-shadow cubic-bezier(.5, 0, .5, 1);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}*/


.resize-box {
  transition: calc(var(--timing) * 1.25) calc(var(--timing) * .25) box-shadow cubic-bezier(.5, 0, .5, 1);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
              
            
!

JS

              
                //const bd = document.body;
const header = document.querySelector('header');
/*const headerTop = document.querySelector('header').getBoundingClientRect().top;

bd.style.setProperty('--top', headerTop)*/

/*let observer = new IntersectionObserver(entries => {
  !entries[0].isIntersecting ?
    bd.classList.add("resize-box") :
    bd.classList.remove("resize-box")
});*/

const observer = new IntersectionObserver( 
  ([e]) => e.target.classList.toggle("resize-box", e.intersectionRatio < 1),
  { threshold: 1 }
);

observer.observe(header);

              
            
!
999px

Console