1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-08-30 00:59:47 +02:00

feat: Sticky header

This commit is contained in:
Phuoc Nguyen
2022-09-21 14:19:27 +07:00
parent fca0ba27f2
commit 8191785762
7 changed files with 56 additions and 141 deletions

View File

@@ -0,0 +1,6 @@
<div class="sticky-header">
<div class="sticky-header__header">
{% rectangle %}
</div>
{% lines "hor", 10 %}
</div>

View File

@@ -117,6 +117,7 @@ eleventyExcludeFromCollections: true
{% pattern "Simple grid" %}{% include "patterns/simple-grid.njk" %}{% endpattern %}
{% pattern "Split screen" %}{% include "patterns/split-screen.njk" %}{% endpattern %}
{% pattern "Sticky footer" %}{% include "patterns/sticky-footer.njk" %}{% endpattern %}
{% pattern "Sticky header" %}{% include "patterns/sticky-header.njk" %}{% endpattern %}
</div>
</div>

31
contents/sticky-header.md Normal file
View File

@@ -0,0 +1,31 @@
---
layout: layouts/post.njk
title: Sticky header
description: Create a sticky header with CSS
keywords: css layout, css position sticky, css sticky header
---
## HTML
```html
<div>
<header class="sticky-header__header">
...
</header>
<main>
...
</main>
</div>
```
## CSS
```css
.sticky-header__header {
/* Stick to the top */
position: sticky;
top: 0;
}
```
{% demo %}{% include "patterns/sticky-header.njk" %}{% enddemo %}