← Back toCSS Layout


Written byPhuoc Nguyen
17 Nov, 2019


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


.notification {
display: flex;
.notification__body {
flex: 1;
margin-right: 0.5rem;
The close button represents the button for closing the notification.
.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: #d1d5db;

/* 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;

Questions? 🙋

Do you have any questions? Not just about this specific post, but about any topic in front-end development that you'd like to learn more about? If so, feel free to send me a message on Twitter or send me an email. You can find them at the bottom of this page.
I have a long list of upcoming posts, but your questions or ideas for the next one will be my top priority. Let's learn together! Sharing knowledge is the best way to grow 🥷.

Recent posts ⚡

Newsletter 🔔

If you're into front-end technologies and you want to see more of the content I'm creating, then you might want to consider subscribing to my newsletter.
By subscribing, you'll be the first to know about new articles, products, and exclusive promotions.
Don't worry, I won't spam you. And if you ever change your mind, you can unsubscribe at any time.
Phước Nguyễn