浮动

为何需要浮动?

  浮动float最开始出现的意义是为了让文字环绕图片而已,但人们发现,如果想要三个块级元素并排显示,都给它们加个float来得会比较方便。

浮动问题?

CSS魔法(三)浮动、相对定位、绝对定位

为何要清除浮动?

  很多情况下父盒子不方便给高度

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    .father {
        border: 1px solid red;
        width: 300px;
    }
    .big {
        width: 100px;
        height: 100px;
        background-color: purple;
        float: left;
    }
    .small {
        width: 80px;
        height: 80px;
        background-color: blue;
        float: left;
    }
    .footer {
        width: 400px;
        height: 100px;
        background-color: pink;
    }
    </style>
</head>
<body>
    <div class="father">
        <div class="big"></div>
        <div class="small"></div>
    </div>
    <div class="footer"></div>
</body>
</html>
View Code

相关文章:

  • 2021-06-26
  • 2021-05-01
  • 2021-10-16
  • 2021-09-19
  • 2021-10-11
  • 2022-01-29
  • 2022-03-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-07
  • 2021-12-01
  • 2022-12-23
  • 2021-05-22
  • 2021-12-03
  • 2021-08-18
相关资源
相似解决方案