Document Открыть Закрыть Заполните форму для верификации
.modal__btn{ border: none; background-color: red; color: #fff; cursor: pointer; } body{ &._locked{ overflow: hidden; } } ._modal{ width: 100%; height: 100vh; position: fixed; top: 0; left: 0; z-index: 10; visibility: hidden; opacity: 0; transition: all .2s; pointer-events: none; &._active{ visibility: visible; pointer-events: all; } } .modal-bg{ width: 100%; height: 100%; background-color: rgba(0, 0, 0, .7); display: flex; } .modal-body{ background-color: #fff; width: 700px; margin: auto; height: 400px; max-height: 90%; overflow: auto; border-radius: 16px; } .modal-close{ margin-left: 30px; cursor: pointer; } .modal-content{ display: flex; align-items: center; flex-direction: column; }
let btns = document.querySelectorAll('._modal-open'); let modals = document.querySelectorAll('._modal'); function openModal(el) { el.classList.add('_active') }; btns.forEach(btn => { btn.addEventListener('click', (e) => { let data = e.target.dataset.modalOpen; modals.forEach(modal => { if(modal.dataset.modal == data || modal.dataset.modal == e.target.closest('._modal-open').dataset.modalOpen) { openModal(modal) } }) }) })
Html SCSS Js