一.clear

清除浮动

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .clearfix:after{   /*善用after和defore*/
            content: "111";  /*注意加引号*/
            clear: both;
            display: block;
            visibility: hidden;  /*隐藏并有高度*/
            height: 0;   /*去掉高度*/
        
        }
        .c{
            width: 100px;
            /*height: 100px;*/
            background-color:red;
        }
        .c .item{
            float:left;
            width:30px;
            background-color: green ;
        }

    </style>
</head>
<body>
    <div class='c clearfix'>
        <div class='item'>123</div>
        <div class='item'>456</div>

    </div>

    <div class="test">内容</div>
</body>
</html>
定义公共样式clearfix

相关文章:

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