Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"modal"
Bootstrap 3.0.0 Snippet by
evarevirus
3.0.0
modal
Preview
HTML
CSS
View Full Screen
Fork
Fork this
5.7K
 
5 Fav
Post to Facebook
Tweet this
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <a href="#Popup" class="button">Expose Modal</a> <div id="Popup" class="Modal"> <div class="content"> <h2>Hey look at me being some content</h2> <p>We all know content needs a friendly sentence.</p> <a href="#" class="cancel">Cancel</a> <span class="close"></div> </div> </div> <script> $.fn.expose = function(options) { var $modal = $(this), $trigger = $("a[href=" + this.selector + "]"); $modal.on("expose:open", function() { $modal.addClass("is-visible"); $modal.trigger("expose:opened"); }); $modal.on("expose:close", function() { $modal.removeClass("is-visible"); $modal.trigger("expose:closed"); }); $trigger.on("click", function(e) { e.preventDefault(); $modal.trigger("expose:open"); }); $modal.add( $modal.find(".close") ).on("click", function(e) { e.preventDefault(); // if it isn't the background or close button, bail if( e.target !== this ) return; $modal.trigger("expose:close"); }); return; } $("#Popup").expose(); // Example Cancel Button $(".cancel").on("click", function(e) { e.preventDefault(); $(this).trigger("expose:close"); }); // Example Callbacks /* $("#Popup").on("expose:opened", function() { alert("Modal Opened!"); }); $("#Popup").on("expose:closed", function() { alert("Modal Closed!"); }); */ </script>
/***********************\ Modal Module - Title CSS FTW \***********************/ .Modal { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: transparent; visibility: hidden; } .Modal .content { position: absolute; left: 50%; top: 30%; width: 50%; padding: 50px; border-radius: 3px; background: #fff; transform: translate(-50%, -30%) scale(0); } .Modal .close { position: absolute; top: 8px; right: 8px; display: block; width: 18px; height: 18px; padding: 5px; line-height: 18px; border-radius: 50%; text-align: center; cursor: pointer; background: #A38CDC; color: #fff; } .Modal .close:before { content: '\2715'; } .Modal.is-visible { visibility: visible; background: rgba(0, 0, 0, 0.5); transition: background .35s; transition-delay: .1s; } .Modal.is-visible .content { transform: translate(-50%, -30%) scale(1); transition: transform .35s; } /***********************\ Pen Specific Styles \***********************/ body { background: #FBFAF5; } .button { display: block; width: 150px; height: 45px; line-height: 45px; margin: 125px auto 0; border-radius: 3px; text-align: center; text-decoration: none; background: #A38CDC; color: #fff; }
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76