小编给大家分享一下css中盒模型的注意点有哪些,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
1、padding不能为负值,margin可以。
2、背景色会平铺到非margin区域。
背景色会平铺到content、padding、border部分。
3、marked在Flexbox或网格布局中,不存在margin-top、bottom叠加及margin-top传递现象。
实例
.box1 {
width: 200px;
height: 200px;
background: pink;
margin-bottom: 30px; 取最高值,所以两个margin叠加,是30px
}
.box2 {
width: 100px;
height: 100px;
background: blue;
margin-top: 20px;
}
看完了这篇文章,相信你对“css中盒模型的注意点有哪些”有了一定的了解,如果想了解更多相关知识,欢迎关注天达云行业资讯频道,感谢各位的阅读!