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

feat: Notification

This commit is contained in:
Phuoc Nguyen
2022-09-20 19:05:13 +07:00
parent f3f89374d1
commit bb0403f0fd
7 changed files with 165 additions and 128 deletions

View File

@@ -0,0 +1,7 @@
<div class="notification">
<div class="notification__body">{% lines "hor", 5 %}</div>
<button class="notification__close">
<div class="notification__close-line notification__close-line--first"></div>
<div class="notification__close-line notification__close-line--second"></div>
</button>
</div>

View File

@@ -73,6 +73,7 @@ eleventyExcludeFromCollections: true
<h2 class="category__name">Feedback</h2>
<div class="category__posts">
{% pattern "Modal" %}{% include "patterns/modal.njk" %}{% endpattern %}
{% pattern "Notification" %}{% include "patterns/notification.njk" %}{% endpattern %}
{% pattern "Popover arrow" %}{% include "patterns/popover-arrow.njk" %}{% endpattern %}
{% pattern "Presence indicator" %}{% include "patterns/presence-indicator.njk" %}{% endpattern %}
{% pattern "Progress bar" %}{% include "patterns/progress-bar.njk" %}{% endpattern %}

93
contents/notification.md Normal file
View File

@@ -0,0 +1,93 @@
---
layout: layouts/post.njk
title: Notification
description: Create a notification with CSS flexbox
keywords: css alert, css flexbox, css notification
---
## HTML
```html
<div class="notification">
<!-- Content -->
<div class="notification__body">
...
</div>
<!-- Close button -->
<button class="notification__close">
<div class="notification__close-line notification__close-line--first"></div>
<div class="notification__close-line notification__close-line--second"></div>
</button>
</div>
```
## CSS
```css
.notification {
display: flex;
}
.notification__body {
flex: 1;
margin-right: 0.5rem;
}
```
The [close button](/close-button/) represents the button for closing the notification.
```css
.notification__close {
/* Reset */
background-color: transparent;
border-color: transparent;
/* Cursor */
cursor: pointer;
/* Size */
height: 1rem;
width: 1rem;
/* Used to position the inner */
position: relative;
}
.notification__close-line {
/* Background color */
background-color: rgba(0, 0, 0, 0.3);
/* Position */
position: absolute;
/* Size */
height: 1px;
width: 100%;
}
.notification__close-line--first {
/* Position */
left: 0px;
top: 50%;
transform: translate(0%, -50%) rotate(45deg);
/* Size */
height: 1px;
width: 100%;
}
.notification__close-line--second {
/* Position */
left: 50%;
top: 0px;
transform: translate(-50%, 0%) rotate(45deg);
/* Size */
height: 100%;
width: 1px;
}
```
{% demo %}
{% include "patterns/notification.njk" %}
{% enddemo %}