Created
August 8, 2013 10:19
-
-
Save libo1106/6183485 to your computer and use it in GitHub Desktop.
未知高度垂直居中
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
<!-- | |
高版本浏览器可以直接使用table-cell配合vertical-align来实现垂直居中。 | |
IE6\7则需要多一个容器,调整定位来实现 | |
--> | |
<style> | |
.wrap{ | |
width:500px;height:300px;border:3px solid #ddd;margin:0 auto;padding:20px;display:table; | |
*position:relative; | |
} | |
.hack{ | |
display:table-cell;vertical-align:middle; | |
*position:absolute;*top:50%; | |
} | |
.cnt{ | |
*position:relative;*top:-50%; | |
} | |
</style> | |
<div class="wrpa"> | |
<div class="hack"> | |
<div class="content"> | |
未知高度的东东 | |
</div> | |
</div> | |
</div> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment