margin-top塌陷

问题描述:当两个盒子嵌套的时候,内部的盒子设置的margin-top会加到外部盒子上,导致内部盒子的margin-top设置失败

解决办法:1.外部盒子设置一个边框

     2. 外部盒子设置 overflow: hidden

     3. 使用伪元素类(类似于加边框)

.clearfix:before{
        content:'';
        display:table   
}

 

相关文章:

  • 2021-07-17
  • 2021-04-30
  • 2022-01-22
  • 2022-12-23
  • 2022-01-30
  • 2022-12-23
  • 2021-08-04
  • 2021-12-08
猜你喜欢
  • 2022-02-10
  • 2022-12-23
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
相关资源
相似解决方案