mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-31 09:31:43 +02:00
feat: Drawer
This commit is contained in:
6
contents/_includes/covers/drawer.njk
Normal file
6
contents/_includes/covers/drawer.njk
Normal file
@@ -0,0 +1,6 @@
|
||||
<div class="drawer">
|
||||
<div class="drawer__sidebar">
|
||||
{% lines "hor", 5 %}
|
||||
</div>
|
||||
<div class="drawer__overlay"></div>
|
||||
</div>
|
65
contents/drawer.md
Normal file
65
contents/drawer.md
Normal file
@@ -0,0 +1,65 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Drawer
|
||||
description: Create a drawer navigation with CSS
|
||||
keywords: css drawer, css off-canvas
|
||||
---
|
||||
|
||||
This pattern is also known as off-canvas.
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<div class="drawer">
|
||||
<!-- Backdrop -->
|
||||
<div class="drawer__overlay"></div>
|
||||
|
||||
<!-- Sidebar -->
|
||||
<div class="drawer__sidebar">
|
||||
...
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.drawer {
|
||||
/* Take full size */
|
||||
height: 100%;
|
||||
left: 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.drawer__overlay {
|
||||
/* Take full size */
|
||||
height: 100%;
|
||||
left: 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
|
||||
/* User still can see the content of main page */
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.drawer__sidebar {
|
||||
/* Take full height */
|
||||
height: 100%;
|
||||
left: 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 200px;
|
||||
|
||||
/* Background */
|
||||
background-color: #fff;
|
||||
}
|
||||
```
|
||||
|
||||
{% demo %}{% include "covers/drawer.njk" %}{% enddemo %}
|
@@ -128,6 +128,7 @@ eleventyExcludeFromCollections: true
|
||||
{% pattern "Breadcrumb" %}{% include "covers/breadcrumb.njk" %}{% endpattern %}
|
||||
{% pattern "Circular navigation" %}{% include "covers/circular-navigation.njk" %}{% endpattern %}
|
||||
{% pattern "Dot navigation" %}{% include "covers/dot-navigation.njk" %}{% endpattern %}
|
||||
{% pattern "Drawer" %}{% include "covers/drawer.njk" %}{% endpattern %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Reference in New Issue
Block a user