Bill_Bryant 2022-08-08 16:22 采纳率: 50%
浏览 76
已结题

伪元素清除浮动失效,求解决方法,是哪里出问题了

伪元素清除浮动失效
<style>
        .one,
        .two,
        .three {
            float: left;
        }

        .one {
            width: 200px;
            height: 400px;
            background-color: antiquewhite;
            filter: blur(1px);
        }

        .two {
            width: 300px;
            height: 400px;
            background-color: rgb(20, 207, 39);
        }

        .three {
            width: 300px;
            height: 400px;
            background-color: rgb(45, 19, 213);
        }

        .clearfix {
            /* height: 100px; */
            border: 1px solid red;
        }

        .clearfix::after {
            content: "";
            display: block;
            height: 0;
            clear: both;
            visibility: hidden;
        }

        .clearfix::after,
        .clearfix::before {
            content: "";
            display: table;
        }
    </style>

<div class="clearfix">
        <div class="one">1111</div>
        <div class="two">22222</div>
        <div class="three">3333333</div>
    </div>

img

  • 写回答

3条回答 默认 最新

  • 关注

    你不是清除成功了吗?

    
    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            .one,
            .two,
            .three {
                float: left;
            }
    
            .one {
                width: 200px;
                height: 400px;
                background-color: antiquewhite;
                filter: blur(1px);
            }
    
            .two {
                width: 300px;
                height: 400px;
                background-color: rgb(20, 207, 39);
            }
    
            .three {
                width: 300px;
                height: 400px;
                background-color: rgb(45, 19, 213);
            }
    
            .clearfix {
                /* height: 100px; */
                border: 1px solid red;
            }
    
            /* 清除伪类 */
            .clearfix::after {
                content: "";
                display: block;
                clear: both;
            }
    
            /* .clearfix::after,
            .clearfix::before {
                content: "";
                display: table;
            } */
    
            .top {
                width: 400px;
                height: 200px;
                background-color: skyblue;
            }
    
            .bottom {
                width: 400px;
                height: 200px;
                background-color: orange;
            }
        </style>
    </head>
    
    <body>
    
        <div class="top"></div>
        <div class="clearfix">
            <div class="one">1111</div>
            <div class="two">22222</div>
            <div class="three">3333333</div>
        </div>
        <div class="bottom"></div>
    </body>
    
    </html>
    

    img


    这个都没有塌陷了

    把我写上注释的那个代码注释掉,类名为 bottom 的元素就塌陷了

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 8月23日
  • 已采纳回答 8月15日
  • 创建了问题 8月8日

悬赏问题

  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站