- 代码
<div class="wrap">
<div class="content">
</div>
</div>
- class
.wrap{
background-color:red;
width:400px;
height:400px;
margin-top:20px;
}
.content{
background-color:red;
width:100px;
height:100px;
margin-top:40px;
}
如上代码内联margin-top失效,如不使用特殊方法会造成margin 塌陷。
解决的办法:
1.overflow:hidden 溢出隐藏
2.display:inline-blok 融合行内于块级
3.position:absolue 绝对定位
可根据自己需求选择。