mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-10-23 10:46:13 +02:00
60 lines
913 B
Markdown
60 lines
913 B
Markdown
---
|
|
layout: layouts/post.njk
|
|
title: Modal
|
|
description: Create a modal with CSS flexbox
|
|
keywords: css dialog, css flexbox, css modal
|
|
---
|
|
|
|
## HTML
|
|
|
|
```html
|
|
<div class="modal">
|
|
<!-- Header -->
|
|
<div class="modal__header">
|
|
<!-- Title -->
|
|
...
|
|
<!-- Close icon sticks to the right -->
|
|
...
|
|
</div>
|
|
|
|
<!-- Content -->
|
|
...
|
|
|
|
<!-- Footer -->
|
|
<div class="modal__footer">
|
|
...
|
|
</div>
|
|
</div>
|
|
```
|
|
|
|
## CSS
|
|
|
|
```css
|
|
.modal {
|
|
/* Border */
|
|
border: 1px solid #d1d5db;
|
|
border-radius: 0.25rem;
|
|
}
|
|
|
|
.modal__header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
|
|
/* Border */
|
|
border-bottom: 1px solid #d1d5db;
|
|
}
|
|
|
|
.modal__footer {
|
|
display: flex;
|
|
/* Push the buttons to the right */
|
|
justify-content: flex-end;
|
|
|
|
/* Border */
|
|
border-top: 1px solid #d1d5db;
|
|
}
|
|
```
|
|
|
|
{% demo %}
|
|
{% include "covers/modal.njk" %}
|
|
{% enddemo %}
|