首页 > 其他 > 详细

div 居中嵌套

时间:2014-02-13 01:00:26      阅读:498      评论:0      收藏:0      [点我收藏+]

将一个 DIV 嵌套进另一个 DIV 容器,并保持水平居中、垂直居中,可使用以下代码:

bubuko.com,布布扣
<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>
bubuko.com,布布扣

div 居中嵌套

原文:http://www.cnblogs.com/easysky/p/3546171.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!