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:
6
contents/_includes/patterns/sticky-header.njk
Normal file
6
contents/_includes/patterns/sticky-header.njk
Normal file
@@ -0,0 +1,6 @@
|
||||
<div class="sticky-header">
|
||||
<div class="sticky-header__header">
|
||||
{% rectangle %}
|
||||
</div>
|
||||
{% lines "hor", 10 %}
|
||||
</div>
|
@@ -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
31
contents/sticky-header.md
Normal 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 %}
|
Reference in New Issue
Block a user