Sukima20th August 2021 at 5:04pm
This is a way to show modals with easy CSS and optional JavaScript.
We can't use the official showModal() as it is not supported by FireFox yet. Till then we can mange with this CSS variant.
.modal {
border: none;
display: none;
position: fixed;
background: transparent;
top: 0;
bottom: 0;
left: 0;
align-items: center;
justify-content: center;
right: 0;
z-index: 9000;
transition: background 1s;
visibility: hidden;
width: 100vw;
height: 100vh;
}
.modal.open,
.modal[open],
.modal:target {
background: rgba(0, 0, 0, 0.5);
display: flex;
visibility: visible;
}
.modal .modal-content {
padding: 20px 20px 10px 20px;
background: #fff;
color: #000;
width: 50vw;
border-radius: 0.4rem;
position: relative;
max-height: calc(100vh - 150px);
display: flex;
flex-direction: column;
}
.modal .modal-content > * {
width: 100%;
}
.modal .modal-body {
overflow-y: auto;
}
.modal .modal-footer {
text-align: right;
}
@media (max-width: 767px) {
.modal.open .modal-content,
.modal:target .modal-content {
width: 70vw;
}
}