Я не могу опубликовать этот довольно простой вопрос без добавления текста, поэтому, пожалуйста, не обращайте внимания на следующее... Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut Labore et dolore magna aliqua.

×

var modal = document.getElementById("Modal");
var btn = document.getElementById("btn");
var span = document.getElementsByClassName("close")[0];
const closeButton = document.getElementById('closeButton');
btn.onclick = function() {
modal.style.display = "block";
}
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
.modal {
display: none;
position: fixed;
z-index: 1;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);
}
.modal-content {
background-color: #fff5ee;
margin: auto;
padding: 20px;
border: 1px solid #c7effb;
width: 80%;
}
.close {
color: #b385dc;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: blueviolet;
text-decoration: none;
cursor: pointer;
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... he-esc-key
Мобильная версия