Created
February 17, 2014 21:08
-
-
Save mishelen/9059157 to your computer and use it in GitHub Desktop.
Вертик. и гориз. центрирование
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
html,body { | |
width: 100%; | |
height: 100%; | |
padding:0; | |
margin:0; | |
} | |
.container { | |
width: 100%; | |
height: 100%; | |
background: #EEE; | |
position: relative; | |
text-align: center; | |
} | |
.container:before { | |
content: ''; | |
display: inline-block; | |
height: 100%; | |
vertical-align: middle; | |
margin-right: -0.25em; | |
} | |
.popup { | |
display: inline-block; | |
vertical-align: middle; | |
width: 100%; | |
max-width: 400px; | |
text-align: left; | |
background: #888; | |
margin: 0 auto; | |
line-height: 1.231; | |
border: 2px solid red; | |
/* IE7 */ | |
*display: block; | |
*margin-top: expression(this.offsetHeight < this.parentNode.offsetHeight ? parseInt((this.parentNode.offsetHeight - this.offsetHeight) / 2) + "px" : "0"); | |
} |
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
/* This parent can be any width and height */ | |
.block { | |
text-align: center; | |
} | |
/* The ghost, nudged to maintain perfect centering */ | |
.block:before { | |
content: ''; | |
display: inline-block; | |
height: 100%; | |
vertical-align: middle; | |
margin-right: -0.25em; /* Adjusts for spacing */ | |
} | |
/* The element to be centered, can | |
also be of any width and height */ | |
.centered { | |
display: inline-block; | |
vertical-align: middle; | |
width: 300px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment