div 居中嵌套
时间:2014-02-13 01:00:26
收藏:0
阅读:499
将一个 DIV 嵌套进另一个 DIV 容器,并保持水平居中、垂直居中,可使用以下代码:
<html> <head> <title>div居中嵌套</title> <style type="text/css"> .big{ width: 800px; height: 500px; background: #333; position: relative; } .small{ width: 400px; height: 200px; position: absolute; left: 50%; top: 50%; margin-left:-200px; margin-top: -100px; background: #fff; } </style> </head> <body> <div class="big"> <div class="small"> div居中嵌套 </div> </div> </body> </html>
原文:http://www.cnblogs.com/easysky/p/3546171.html
评论(0)