シンプルなモーダルウインドウです。
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width">
<title>Document</title>
<script src="http://code.jquery.com/jquery-3.2.1.js"></script>
<script src="scripts.js"></script>
<style>
*,
*::before,
*::after {
box-sizing: inherit;
}
html {
box-sizing: border-box;
}
.modal {
position: absolute;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0;
margin: 0;
opacity: 0;
transition: opacity 0.3s ease;
}
.modal.is-show {
z-index: 99;
overflow: visible;
visibility: visible;
opacity: 1;
}
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: rgba(0,0,0,0.4);
cursor: pointer;
}
.modal-window {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
display: inline-block;
width: 90%;
max-width: 940px;
padding: 20px;
border-radius: 5px;
background-color: #fff;
}
.modal-body {
max-height: calc(90vh - 40px);
overflow-y: auto;
}
.modal-close {
position: absolute;
top: 0;
right: 0;
cursor: pointer;
}
</style>
<script>
$(function() {
$('[href^="#modal-"]').on('click', function(e) {
var $modal = $($(this).attr('href'));
$modal.addClass('is-show');
$modal.find('.modal-close,.modal-overlay').on('click', function() {
$modal.removeClass('is-show');
});
e.preventDefault();
});
});
</script>
</head>
<body>
<p><a href="#modal-01">modal-01 open</a></p>
<div id="modal-01" class="modal">
<div class="modal-overlay"></div>
<div class="modal-window">
<div class="modal-close">x</div>
<div class="modal-body">
<p>
モーダル<br>
モーダル<br>モーダル<br>モーダル<br>モーダル<br>モーダル<br>モーダル<br>モーダル<br>モーダル<br>モーダル<br>モーダル<br>モーダル<br>モーダル<br>モーダル<br>モーダル<br>モーダル<br>
</div>
</div>
</div>
</body>
</html>
以上