Some text..
Some text..
<div class="showcontent">
<h3>Click the modal button & see how it's works</h3>
<button class="modalbtn">Modal</button>
<div class="modalbox" id="mymodal">
<div class="modalrow">
<span onclick="this.parentElement.parentElement.style.display='none';">X</span>
<div class="modalheader">
<h2>My Header</h2>
</div>
<div class="modalcontent">
<p>Some text..</p>
<p>Some text..</p>
<h4>Or contain any type form</h4>
</div>
<div class="modalfooter">
<h2>Footer</h2>
</div>
</div>
</div>
</div>
window.onclick = function (event) {
//console.log(event.target.className);
let showed=document.querySelector(".modalbox");
if (event.target.className == "modalbtn") {
showed.style.display="block";
}
//console.log(event.target.parentElement.className);
}
.modalbox {
width: 80%;
height: 100%;
background-color: rgba(0, 0, 0, 0.628);
color: white;
position: fixed;
top: 0;
padding-top: 100px;
overflow: hidden;
z-index: 100;
left: 20%;
animation-name: ex;
animation-timing-function: ease-in-out;
animation-duration: 1.4s;
display: none;
}
@keyframes ex {
from {
top: -300px;
opacity: 0.5;
}
to {
top: 0;
opacity: 0.8;
}
}
.modalrow {
position: relative;
width: 90%;
margin: auto;
background-color: rgb(217, 255, 0);
box-shadow: 2px 2px 3px 2px black;
}
.modalcontent {
padding-left: 8px;
color: black;
}
.modalheader,
.modalfooter {
background-color: rgb(30, 255, 124);
padding: 8px;
display: flex;
align-items: center;
justify-content: center;
}
.modalbtn {
border: none;
padding: 10px 16px;
border-radius: 5px;
background-color: #04AA6A;
color: white;
font-size: 18px;
cursor: pointer;
font-weight: bold;
}
.modalrow span {
position: absolute;
right: 10px;
top: 5px;
color: red;
font-size: 25px;
cursor: pointer;
}