好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

"margin塌陷现象"div盒子嵌套盒子外边距合并现象_html/css_WEB-ITnose

问题描述:原型大概是“一个div嵌套了两个 div,给main设定了background="pink" ,header1设定background=“red” 。header2 设定background=“blue” ,同时给heder1 设定margin-top:10px; 预想的是内层 heder1div 的上边距 maindiv 上边有10px的距离 但事实上 出现一个问题 ,内层div 并没有出现他所预想的那种效果,实际效果是 maindiv 仍然紧贴内层div 整个maindiv 上边框距离浏览器上边 增加了10px 的外边距”

问题描述代码:

             Document          *{margin: 0;padding: 0;}    .main{        width: 400px;        height: 400px;        background: pink;    }    .header1{        width: 150px;        height: 150px;        background-color: red;
margin-top:10px; } .header2{ width: 150px; height: 150px; background-color: blue; }

查看更多关于"margin塌陷现象"div盒子嵌套盒子外边距合并现象_html/css_WEB-ITnose的详细内容...

  阅读:30次