<header class="sticky-header">
<div class="logo">MySite</div>
<nav>
<a href="#section1">Section 1</a>
<a href="#section2">Section 2</a>
<a href="#section3">Section 3</a>
</nav>
</header>
<main class="page-content">
<section id="section1" style="height: 600px; background-color: #e9f7ef;"><h1>Section 1</h1></section>
<section id="section2" style="height: 600px; background-color: #fdecea;"><h1>Section 2</h1></section>
<section id="section3" style="height: 600px; background-color: #eaf2f8;"><h1>Section 3</h1></section>
</main>
Back to Snippets
CSS Sticky Header Navigation
Create a sticky header or navigation bar that stays fixed at the top of the viewport when the user scrolls. This simple CSS snippet uses `position: sticky` for improved site navigation.