Created
April 26, 2017 14:52
-
-
Save default-writer/79f392072ae05761b60048835db59d64 to your computer and use it in GitHub Desktop.
How to center modal window on the screen using CSS
This file contains hidden or 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
.container { | |
position: absolute; | |
padding: 0; | |
margin: 0; | |
left: 0; | |
top: 0; | |
width: 100vw; /* margin: 0 and width: 100vw: | |
100vw means the same as width:100% including the document margin, | |
100vw is calculated relative to document layout including document margin, | |
100% is calculated relative to parent layout */ | |
height: 100vh; | |
} | |
.modal { | |
position: absolute; | |
left: 50%; | |
top: 50%; | |
transform: translate(-50%,-50%); | |
} | |
.container-color { | |
background-color: rgba(127,127,127,0.1); | |
} | |
.modal-color { | |
-webkit-border-radius: 4px; | |
-moz-border-radius: 4px; | |
-ms-border-radius: 4px; | |
-o-border-radius: 4px; | |
border-radius: 4px; | |
background: rgba(255, 255, 255, 1); | |
-webkit-box-shadow: 0px 1px 5px 0px rgba(127, 127, 127, .35); | |
-moz-box-shadow: 0px 1px 5px 0px rgba(127, 127, 127, .35); | |
-ms-box-shadow: 0px 1px 5px 0px rgba(127, 127, 127, .35); | |
-o-box-shadow: 0px 1px 5px 0px rgba(127, 127, 127, .35); | |
box-shadow: 0px 1px 5px 0px rgba(127, 127, 127, .35); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment