Created
September 26, 2014 04:43
-
-
Save hacke2/5b9878bc2b2e473dbfc2 to your computer and use it in GitHub Desktop.
IE8下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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<style> | |
.outer { | |
display: table; | |
width: 500px; | |
height: 300px; | |
border: 1px solid #ccc; | |
margin: 0 auto; | |
text-align: center; | |
*position: relative; | |
} | |
.inner { | |
display: table-cell; | |
vertical-align: middle; | |
*position: absolute; | |
*top: 50%; | |
} | |
.inner div { | |
height: 50px; | |
width: 100px; | |
display: inline-block; | |
overflow: hidden; | |
*display: block; | |
background: #ccc; | |
*position: relative; | |
*top: -50%; | |
*left: -50%; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="outer"> | |
<div class="inner"> | |
<div>垂直水平居中</div> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment