A pop-up is usually a small window that appears in front of the original web page.
It is a graphical user interface(GUI) display area. The pop-up window opens on the single or double click and can be occured in a particular time period.
The size of the pop-up window must be smaller than the original window. Pop-up is used to add interactive effects.
Below is the example of Custom pop-up:-
HTML-
Here is the HTML for the custom popup, you can change it according to your need.
<a class="btn" id="popup_open" href="#">Click to open popUp</a>
<div class="popup" data-popup="popup-1">
<div class="popup-inner">
<h2>Custom PopUp</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.</p>
<a class="popup-close" id="popup_close" href="#">x</a>
</div>
</div>
CSS-
Below is the CSS for the pop-up.
.btn{
background-color: #FF5050;
color: #fff;
}
.popup {
width:100%;
height:100%;
display:none;
position:fixed;
top:0px;
left:0px;
background:rgba(0,0,0,0.75);
}
.popup-inner {
max-width:700px;
width:90%;
padding:40px;
position:absolute;
top:50%;
left:50%;
-webkit-transform:translate(-50%, -50%);
transform:translate(-50%, -50%);
box-shadow:0px 2px 6px rgba(0,0,0,1);
border-radius:3px;
background:#fff;
}
.popup-close {
width:30px;
height:30px;
padding-top:4px;
display:inline-block;
position:absolute;
top:0px;
right:0px;
border-radius:1000px;
background:rgba(0,0,0,0.8);
font-size:20px;
text-align:center;
line-height:100%;
color:#fff;
}
JAVASCRIPT-
On click of a button the popup is opened using jQuery.
$(function() {
$('#popup_open').on('click', function(e) {
$(".popup").show().fadeIn('fast');
e.preventDefault();
});
$('#popup_close').on('click', function(e) {
$(".popup").show().fadeOut(350);
e.preventDefault();
});
});
We can test the popup in below link-
https://jsfiddle.net/z4x3r84r/
0 Comment(s)