<style>
main {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
header {
position: -webkit-sticky;
top: 0;
z-index: 1;
padding: 40px;
border-top: 1px solid blue;
border-right: 1px solid green;
border-bottom: 1px solid black;
border-left: 1px solid red;
background-color: lightgrey;
}
section {
position: relative;
padding: 80px;
}
</style>
<main>
<div class="wrapper">
<header>Level 1 Header</header>
<section>
Level 1 Content
<div class="wrapper">
<header>Level 2 Header</header>
<section>
Level 2 Content
<div class="wrapper">
<header>Level 3 Header</header>
<section>Level 3 Content</section>
</div>
<div class="wrapper">
<header>Level 3 Header</header>
<section>Level 3 Content</section>
</div>
</section>
<header>Level 2 Header</header>
<section>
Level 2 Content
<div class="wrapper">
<header>Level 3 Header</header>
<section>Level 3 Content</section>
</div>
<div class="wrapper">
<header>Level 3 Header</header>
<section>Level 3 Content</section>
</div>
</section>
</div>
<div class="wrapper">
<header>Level 2 Header</header>
<section>
Level 2 Content
<div class="wrapper">
<header>Level 3 Header</header>
<section>Level 3 Content</section>
</div>
<div class="wrapper">
<header>Level 3 Header</header>
<section>Level 3 Content</section>
</div>
</section>
<header>Level 2 Header</header>
<section>
Level 2 Content
<div class="wrapper">
<header>Level 3 Header</header>
<section>Level 3 Content</section>
</div>
<div class="wrapper">
<header>Level 3 Header</header>
<section>Level 3 Content</section>
</div>
</section>
</div>
</section>
</div>
</main>