This time I will share jQuery Plugin and tutorial about Fancy Inline Modal With jQuery And Animate.css – popup.js, hope it will help you in programming stack.
File Size: | 6.33 KB |
---|---|
Views Total: | 620 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
popup.js is a super tiny jQuery plugin to create a static inline modal popup with fancy CSS3 transitions based on Animate.css library.
How to use it:
1. Load the necessary jQuery library and animate.css from a CDN.
1 |
< script src = "/path/to/cdn/jquery.min.js" ></ script > |
2 |
< link rel = "stylesheet" href = "/path/to/cdn/animate.min.css" /> |
2. Insert your modal content together with a close button into the document.
1 |
< div id = "my<a href=" https://www.jqueryscript.net/tags.php?/Modal/">Modal</ a >" class="myModal"> |
2 |
<!-- Modal Content Here --> |
3 |
< h3 >Modal Title</ h3 > |
4 |
< p >Modal Body</ p > |
5 |
<!-- Custom Close Button --> |
6 |
< b class = "myModal-close js-popup-close" >x</ b > |
7 |
</ div > |
3. Download and include the popup.js
script after jQuery.
1 |
< script src = "jquery.popup.min.js" ></ script > |
4. Call the function to launch the modal popup on page load.
1 |
$( '#myModal' ).popup(); |
5. Apply CSS styles to the modal popup.
1 |
.myModal { |
2 |
max-width : 600px ; |
3 |
padding : 1em ; |
4 |
background : #eee ; |
5 |
display : none ; |
6 |
position : relative ; |
7 |
box-shadow: 0px 0px 15px 0px rgba( 0 , 0 , 0 , 0.15 ); |
8 |
} |
6. Style the close button whatever you like.
01 |
.item-close { |
02 |
cursor : pointer ; |
03 |
right : 5px ; |
04 |
top : 5px ; |
05 |
position : absolute ; |
06 |
background : #222 ; |
07 |
color : #fff ; |
08 |
border-radius: 100% ; |
09 |
font-size : 14px ; |
10 |
height : 24px ; |
11 |
line-height : 22px ; |
12 |
text-align : center ; |
13 |
width : 24px ; |
14 |
} |
7. Apply fancy animations to the modal using Animate.css classes. Default: none.
1 |
$( '#myModal' ).popup({ |
2 |
classAnimateShow: 'slideInUp' , |
3 |
classAnimateHide: 'fadeOut' |
4 |
}); |
8. Specify the animation speed. Default: 400.
1 |
$( '#myModal' ).popup({ |
2 |
time: 1000 |
3 |
}); |
9. Customize the appearance of the modal popup.
1 |
$( '#myModal' ).popup({ |
2 |
background: "#000" , |
3 |
position: "absolute" , |
4 |
opacity: .5, |
5 |
zIndex: 123456788, |
6 |
}); |
10. Execute a callback function after the modal is closed.
1 |
$( '#myModal' ).popup({ |
2 |
onPopupClose: function (e) { |
3 |
// do something |
4 |
} |
5 |
}); |
11. Execute a callback function on init.
1 |
$( '#myModal' ).popup({ |
2 |
onPopupInit: function (e) { |
3 |
// do something |
4 |
} |
5 |
}); |
12. Close the modal popup manually.
1 |
$( '#myModal' ).popup( 'close' ); |
This awesome jQuery plugin is developed by romamaslennikov. For more Advanced Usages, please check the demo page or visit the official website.
source : jquery.net