Modal is used to show a dialog or a box when you click a button.
Class name | Type | |
---|---|---|
modal | Component | Container element |
modal-box | Component | The content of modal |
modal-action | Component | Container for modal action buttons |
modal-backdrop | Component | The backdrop that covers the back of modal so we can close the modal by clicking outside |
modal-toggle | Component | For hidden checkbox that controls modal |
modal-open | Modifier | Add/remove this class to open/close the modal using JS |
modal-top | Responsive | Moves the modal to top |
modal-bottom | Responsive | Moves the modal to bottom |
modal-middle | Responsive | Moves the modal to middle (default) |
<dialog>
element: It needs JS to open but it has better accessibility and we can close it using Esc key<input type="checkbox">
and <label>
to check/uncheck the checkbox and open/close the modal<a>
anchor links: A link adds a parameter to the URL and you only see the modal when the URL has that parameterThis modal works with a hidden checkbox!
You've been selected for a chance to get one year of subscription to use Wikipedia for free!