<!DOCTYPE html>
<html>
<head>
<title>Content Responsive Popup in Pure JavaScript</title>
<meta name="description" content="Content Responsive Popup in Pure JavaScript">
<meta name="keyword" content="Content Responsive Popup, in Pure JavaScript,reposnive popup, model">
<meta name="auhor" content="Md Hidaytullah Rahmani">
<style>
/* The popup-wrapper */
.popup-wrapper {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 999; /* Sit on top */
    padding-top: 100px; /* Location of the box */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

/* Popup Content */
.popup-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
	position:relative;
}

/* The Close Button */
.close {
    color: #FFFFFF;
    float: right;
    font-size: 21px;
    background: red;
    position: absolute;
    right: -10px;
    top: -10px;
    padding: 2px 5px;
    border: 1px #FFFFFF solid;
    font-family: arial;
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}
</style>
</head>
<body>

<h2>Content Responsive Popup in Pure JavaScript</h2>

<!-- Trigger/Open The Modal -->
<button id="myBtn">Open Modal</button>

<!-- The Modal -->
<div id="contentPopup" class="popup-wrapper">

  <!-- Modal content -->
  <div class="popup-content">
    <span class="close">X</span>
    <p>Some text in the Modal..</p>
  </div>

</div>

<script>
// Get the contentPopup
var contentPopup = document.getElementById('contentPopup');

// Get the button that opens the contentPopup
var btn = document.getElementById("myBtn");

// Get the <span> element that closes the contentPopup
var span = document.getElementsByClassName("close")[0];

// When the user clicks the button, open the contentPopup
btn.onclick = function() {
    contentPopup.style.display = "block";
}

// When the user clicks on <span> (x), close the contentPopup
span.onclick = function() {
    contentPopup.style.display = "none";
}

// When the user clicks anywhere outside of the contentPopup, close it
window.onclick = function(event) {
    if (event.target == contentPopup) {
        contentPopup.style.display = "none";
    }
}
</script>

</body>
</html>