Dev Helpers
← Back

Keep a subheading visible while scrolling

Keep a subheading visible while scrolling with native CSS. The preview includes a small shared demo stylesheet.

Open this example in the interactive library

Source code

<style>
  .demo {
    height: 7rem;
    overflow: auto;
  }
  .demo .tile {
    position: sticky;
    top: 0;
  }
</style>
<div class="demo">
  <div class="tile">Pinned heading</div>
  <p style="height: 12rem">
    Scroll this panel to see the heading stay in place.
  </p>
</div>