美文网首页
垂直方向外边距塌陷

垂直方向外边距塌陷

作者: web_jianshu | 来源:发表于2020-07-22 08:58 被阅读0次
未处理前
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <style type="text/css">
      /* 方案1: 给外边的大盒子使用overflow:hidden; */
      /* .father {
        width: 500px;
        height: 300px;
        background: #eee;
        overflow: hidden;
      } */
      
      /* 方案2: 给外边的大盒子定义边框 */
      .father {
        width: 500px;
        height: 299px;
        border-top: 1px solid #eee;
        background: #eee;
      }
      .son {
        width: 100px;
        height: 100px;
        background: red;
        margin-top: 50px;
      }
    </style>
  </head>
  <body>
    <div class="father">
      <div class="son"></div>
    </div>
  </body>
</html>
处理后

相关文章

网友评论

      本文标题:垂直方向外边距塌陷

      本文链接:https://www.haomeiwen.com/subject/tmzakktx.html