<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
.clear { zoom:1; }
.clear:after { content:''; display:block; clear:both; }

.wrap { padding-bottom:10px; }

#div1 { width:100px; height:100px; background:red; float:left; }

#div2 { width:200px; height:100px; background:yellow; }
</style>
</head>

<body>

<div class="wrap clear">
    <div id="div1"></div>
</div>

<div id="div2"></div>

</body>
</html>

上面的css代码中如果给div1加margin-bottom是没用的,解决办法就是给div1的父级家padding-bottom

posted on 2015-03-14 12:15  toodeep  阅读(171)  评论(0编辑  收藏  举报