How to create a custom popup using jquery and css
Full code for custom popup using jquery. Includes HTML, CSS, jQuery. This will show a popup on a button click. And close popup on clicking on X button.
Video tutorial for custom jquery popup: https://www.youtube.com/watch?v=zK4nXa84Km4
Source Code:
<!DOCTYPE html>
<html>
<head>
<title>How to create a custom popup using jquery and css | MG Technologies</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="jquery-1.js" type="text/javascript"></script>
<style>
.pop-outer {
background-color: rgba(0, 0, 0, 0.5);
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.pop-inner {
background-color: #fff;
width: 500px;
height: 300px;
padding: 25px;
margin: 5% auto;
}
</style>
<script>
$(document).ready(function (){
$(".open").click(function (){
$(".pop-outer").fadeIn("slow");
});
$(".close").click(function (){
$(".pop-outer").fadeOut("slow");
});
});
</script>
</head>
<body>
<button class="open">Click to open popup</button>
<div style="display: none;" class="pop-outer">
<div class="pop-inner">
<button class="close">X</button>
<h2>This is a custom pop-up example</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
</div>
</body>
</html>
Get updates!
Follow @themgtechnologyCompatible Browsers
Chrome, Firefox, Safari, Opera, IE9+, Edge
Technologies Used
HTML 5, CSS 3, JS, jQuery