<!-- The Popup Modal --> <div id="mkpopup" class="mkpopup"> <!-- Modal content --> <div class="mkpopup-content"> <span class="mkpopupclose" onclick="closmkpopup();">×</span> <h3>Get in touch</h3> <form method="post" name="popupcontact" onsubmit="popupvalidation();" action="#"> <div class="col-md-12"> <lable>Name <span class="required">*</span></lable> <input type="text" name="username"> </div> <div class="col-md-12"> <lable>Email <span class="required">*</span></lable> <input type="text" name="uemail"> </div> <div class="col-md-12"> <lable>Phone No. <span class="required">*</span></lable> <input type="text" name="uphoneno"> </div> <div class="col-md-12"> <lable>Message <span class="required">*</span></lable> <textarea name="umessage" placeholder="" style="height: 130px;"></textarea> </div> <div class="col-md-12"> <input type="submit" name="popupcontact" value="Get in touch now"> </div> </form> <div class="clearfix"></div> </div> <div class="clearfix"></div> </div> <input type="button" value="Open Popup" onclick="openmkpopup();">
<style> /*Popup CSS*/ .mkpopup { display: none; /* Hidden by default */ position: fixed; /* Stay in place */ z-index: 99999999; /* 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 */ } /* Modal Content */ .mkpopup-content { background-color: #fefefe; margin: auto; padding: 20px; border: 1px solid #888; width: 100%; max-width:700px; } /* The Close Button */ .mkpopupclose { color: #aaaaaa; float: right; font-size: 28px; font-weight: bold; } .mkpopupclose:hover, .mkpopupclose:focus { color: #000; text-decoration: none; cursor: pointer; } input[type="text"], textarea{width:100%; border:1px solid #cccccc; margin-bottom:10px; padding:5px;} </style>
<script> function openmkpopup(){ document.getElementById("mkpopup").style.display = "block"; } function closmkpopup(){ document.getElementById("mkpopup").style.display = "none"; } </script>
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>How To Create a Modal Popup With CSS and JavaScript</title> <style> /*Popup CSS*/ .mkpopup { display: none; /* Hidden by default */ position: fixed; /* Stay in place */ z-index: 99999999; /* 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 */ } /* Modal Content */ .mkpopup-content { background-color: #fefefe; margin: auto; padding: 20px; border: 1px solid #888; width: 100%; max-width:700px; } /* The Close Button */ .mkpopupclose { color: #aaaaaa; float: right; font-size: 28px; font-weight: bold; } .mkpopupclose:hover, .mkpopupclose:focus { color: #000; text-decoration: none; cursor: pointer; } input[type="text"], textarea{width:100%; border:1px solid #cccccc; margin-bottom:10px; padding:5px;} </style> <script> function openmkpopup(){ document.getElementById("mkpopup").style.display = "block"; } function closmkpopup(){ document.getElementById("mkpopup").style.display = "none"; } </script> </head> <body> <!-- The Popup Modal --> <div id="mkpopup" class="mkpopup"> <!-- Modal content --> <div class="mkpopup-content"> <span class="mkpopupclose" onclick="closmkpopup();">×</span> <h3>Get in touch</h3> <form method="post" name="popupcontact" onsubmit="popupvalidation();" action="#"> <div class="col-md-12"> <lable>Name <span class="required">*</span></lable> <input type="text" name="username"> </div> <div class="col-md-12"> <lable>Email <span class="required">*</span></lable> <input type="text" name="uemail"> </div> <div class="col-md-12"> <lable>Phone No. <span class="required">*</span></lable> <input type="text" name="uphoneno"> </div> <div class="col-md-12"> <lable>Message <span class="required">*</span></lable> <textarea name="umessage" placeholder="" style="height: 130px;"></textarea> </div> <div class="col-md-12"> <input type="submit" name="popupcontact" value="Get in touch now"> </div> </form> <div class="clearfix"></div> </div> <div class="clearfix"></div> </div> <input type="button" value="Open Popup" onclick="openmkpopup();"> </body> </html>
My name is Mukesh Jakhar and I am a Web Application Developer and Software Developer, currently living in Jaipur, India. I have a Master of Computer Application in Computer Science from JNU Jaipur University. I loves to write on technology and programming topics. Apart from this, I love to travel and enjoy the beauty of nature.