Last active
December 24, 2015 05:28
-
-
Save petrosh/6750357 to your computer and use it in GitHub Desktop.
Simple modal box as seen on http://stackoverflow.com/a/11090278
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* White | |
* | |
*/ | |
#modal-background { | |
display: none; | |
position: fixed; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
background-color: white; /* << change this for black */ | |
opacity: .50; | |
-webkit-opacity: .5; | |
-moz-opacity: .5; | |
filter: alpha(opacity=50); | |
z-index: 1000; | |
} | |
#modal-content { | |
background-color: whitesmoke; /* << change this for black */ | |
display: none; | |
height: 480px; | |
width: 640px; | |
margin: -240px 0 0 -320px; /* << margins = half width and height */ | |
padding: 10px; | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
z-index: 1000; | |
} | |
#modal-background.active, #modal-content.active { | |
display: block; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button id="modal-launcher">Launch Modal Window</button> | |
<div id="modal-background"></div> | |
<div id="modal-content"> | |
<button id="modal-close">Close Modal Window</button> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
$("#modal-launcher, #modal-background, #modal-close").click(function() { | |
$("#modal-content, #modal-background").toggleClass("active"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment