Skip to content

Instantly share code, notes, and snippets.

@jasonbellamy
Last active August 29, 2015 14:16
Show Gist options
  • Save jasonbellamy/9024d9f7dbea10b2416f to your computer and use it in GitHub Desktop.
Save jasonbellamy/9024d9f7dbea10b2416f to your computer and use it in GitHub Desktop.
Modal overlay created using CSS fixed positioning.
<div class="modal">
<div class="modal-content">
modal content
</div>
<div class="modal-overlay"></div>
</div>
.modal {
width: 100%;
height: 100%;
position: fixed;
}
.modal-content {
background: red;
color: rgb(255, 255, 255);
width: 25%;
padding: 1em;
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.modal-overlay {
background-color: rgba(0,0,0,0.5);
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment