1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-10-24 11:16:27 +02:00
Files
csslayout/contents/sticky-sections.md
2022-09-21 14:31:37 +07:00

41 lines
633 B
Markdown

---
layout: layouts/post.njk
title: Sticky sections
description: Create sticky sections with CSS
keywords: css layout, css sticky, css sticky sections
---
## HTML
```html
<div class="sticky-sections">
<section class="sticky-sections__section">
...
</section>
<!-- Repeat other sections -->
...
</div>
```
## CSS
```css
.sticky-sections {
height: 100%;
overflow: scroll;
}
.sticky-sections__section {
/* Take full size */
height: 100%;
width: 100%;
/* Stick to the top */
position: sticky;
top: 0;
}
```
{% demo %}{% include "covers/sticky-sections.njk" %}{% enddemo %}