盒子塌陷问题
(一)上下盒子塌陷問題
上盒子定義下外邊距,下盒子定義上外邊距時,兩盒子之間的距離并不是(margin-bottom) +( margin-top)的距離,而是兩者之間的最大值。
(二)嵌套盒子塌陷問題
<style>*{margin: 0;padding: 0;}.a{width: 200px;height: 200px;background-color: aqua;margin-left: 400px;}.a1{width: 50px;height: 50px;background-color: black;margin-top: 100px;}</style> <body><div class="a"><div class="a1"></div></div> </body>以上便是盒子塌陷的問題;解決辦法如下:1.父盒子設置透明的上邊框;
2.父盒子設置padding內邊距,這樣就不用再設置內盒子的上外邊距了;
3.父盒子添加overflow:hidden;
4.父盒子添加display:inline-block;
5:父盒子添加float浮動;
6.父盒子添加絕對定位position:absolute;
總結
- 上一篇: 计算机教师幽默介绍,老师幽默的自我介绍6
- 下一篇: Oracle全文索引