Skip to content

Instantly share code, notes, and snippets.

@hacke2
Created September 26, 2014 04:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hacke2/5b9878bc2b2e473dbfc2 to your computer and use it in GitHub Desktop.
Save hacke2/5b9878bc2b2e473dbfc2 to your computer and use it in GitHub Desktop.
IE8下DIV居中
<!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