lyongde

按正常理解,如果纵向相邻两个元素有设置外边距(margin),它们之间的距离是两个上下边距之和,如下:

1 <div style="margin-bottom:20px;background-color:#ff0000;">first</div>
2 <div style="margin-top:30px;background-color:#00ff00;">second</div>

实际并非如此,详情请阅读Collapsing Margins了解更多关于外边距复杂之处,两个纵向的无定位(position:static)元素相邻的外边距(margin)会叠加成为其中一个较大的外边距的值,并非是两者的和。

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-11-02
  • 2021-08-03
  • 2022-12-23
  • 2021-11-29
  • 2021-07-26
  • 2021-11-30
  • 2022-01-16
猜你喜欢
  • 2021-12-29
  • 2022-12-23
  • 2021-12-21
  • 1970-01-01
  • 2022-12-23
  • 2021-08-19
  • 2022-01-15
相关资源
相似解决方案