一路繁花似锦绣前程
失败的越多,成功才越有价值

导航

 

一、塌陷问题

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style type="text/css">
    .out {
      width: 300px;
      background: red;
      overflow: hidden;
    }

    /*.out:before {
      content: "";
      display: table;
    }*/

    .in {
      width: 100px;
      height: 100px;
      background: green;
      margin-top: 100px;
      float: left;
    }
  </style>
</head>
<body>
<div class="out">
  <div class="in"></div>
</div>
</body>
</html>

 二、清除浮动和宽高计算方式

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        .out {
            width: 350px;
            background: red;
        }

        .in {
            width: 100px;
            height: 100px;
            box-sizing: border-box;/*border+padding+content=width*/
            background: green;
            border: 10px solid blue;
            float: left;
        }
    </style>
</head>
<body>
<div class="out">
    <div class="in"></div>
    <div class="in"></div>
    <div class="in"></div>
    <div class="in"></div>
    <div class="in"></div>
    <div class="in"></div>
    <!--清除浮动-->
    <div style="clear: both"></div>
</div>
</body>
</html>

 

posted on 2020-08-26 17:07  一路繁花似锦绣前程  阅读(273)  评论(0编辑  收藏  举报