给子元素margin-top时,若这个子元素前面没有其他内容,这个margin-top值会应用到父元素上
解决方案,给父元素设置:before
#content{
height: 80px;
width: 100%;
background: red;
}
#header{
height: 60px;
width: 100%;
background: blue;
margin-top: 20px;
}
#content:before{
content: "";
display: table;
}