漫游的备忘录
让页面元素或div水平和垂直居中的CSS
2011-12-2 漫游

<style type="text/css">

<!--

.main{width:600px; height:400px; top:50%; left:50%; margin-top:-200px; margin-left:-300px; position:absolute;}

-->

</style>

<div class="main">

</div>


看一下就明白了,很简单吧?定义好DIV容器的宽和高,定位用绝对,然后高和左通过人工计算设定距离就达到效果了。