您的位置:首页 > 运维架构

嵌套的margin-top无效

2013-06-04 15:52 169 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>margin-top无效</title>
</head>
<style>
body{ padding:0; margin:0; background:#cccccc;}
.box1{ width:500px; margin:0 auto; background:yellow; overflow:hidden;}
.box2{ width:100px; height:100px; border:1px #000 solid; margin-top:10px;}
</style>
<body>
<div class="box1">
<div class="box2">box2</div>
box1
</div>
</body>
</html>


ie6下:



谷歌下:



解决方法:

在外层样式加:overflow:hidden;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: