<button id="openModal">ボタンをクリック</button>

<div id="myModal" class="modal">
  <div class="modal-content">
    <span id="closeModal">&times;</span>
    <p>落ち着いたカラーで表示</p>
  </div>
</div>
.modal {
  display: none;
  position: fixed;
  z-index: 1;
  padding-top: 100px;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.4);
}

.modal-content {
  margin: auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  background-color: #fff;
  border-radius: 20px;
  box-shadow: 0 4px 16px 0 rgba(0,0,0,0.2);
  background-color: #457b9d;
  color: white;
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

.close:hover,
.close:focus {
  color: white;
  text-decoration: none;
  cursor: pointer;
}

button {
  background-color: #1d3557;
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
  border-radius: 4px;
}


var modal = document.getElementById("myModal");
var btn = document.getElementById("openModal");
var span = document.getElementById("closeModal");

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";
  }
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.