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

关于margin-top溢出父节点元素的处理方法

2016-11-02 16:33 260 查看
给子元素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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: