<header class="header"><h1>Header</h2>
<nav>Nav stuff or whatever</nav>
</header>
<main class="main">
<h2>Scrollable section</h2>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
<p>Content to scroll</p>
</main>
<footer>Footer</footer>
html {
box-sizing: border-box;
background: #666;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
html,
body {
margin: 0;
padding: 0;
}
body {
display: flex;
min-height: 100vh;
flex-direction: column;
max-width: 1280px;
margin: auto;
}
.main {
flex: 1;
background: #ccc;
padding: 10px;
}
header,
footer,
nav {
background: green;
}
header {
position: sticky;
top: 0;
}
footer {
position: sticky;
bottom: 0;
padding: 10px;
}
h1,
nav {
padding: 10px;
}
nav {
background: red;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.