1
0
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:
Phuoc Nguyen
2022-09-21 15:36:23 +07:00
parent 9c2641ef15
commit b7bd6a9d0a
7 changed files with 94 additions and 152 deletions

View 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
View 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 %}

View File

@@ -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>