Код: Выделить всё
let clickMe = document.querySelector('#click-me'),
modal = document.querySelector('.modal'),
closeButton = document.querySelector('.close')
clickMe.addEventListener('click', () => {
modal.style.display = 'flex';
// modal.focus();
})
closeButton.addEventListener('click', () => {
modal.style.display = 'none';
})< /code>
body {
margin: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
input, button {
margin: 1rem;
padding: .5rem;
}
.click-me {
display: block;
}
.modal {
display: none;
flex-direction: column;
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
background: grey;
position: absolute;
}
form {
display: flex;
}< /code>
Click Me
Close x
More Buttons
More Buttons
Подробнее здесь: https://stackoverflow.com/questions/720 ... javascript
Мобильная версия