CSS:浏览器窗口缩小时,浮动元素换行问题

一、问题描述

1、浏览器默认缩放80%以上状态下的样式
在这里插入图片描述
自定义浏览器缩放80%以下时的样式,
可以看到明显错位了
在这里插入图片描述
查看代码html

        <div class="footer">
            <div class="footer-top">
                <div class="f-t-box">
                    <div class="f-t-content">
                        <img src="../img/foot1.png" alt="">
                        <span>7天无理由退货</span>
                    </div>
                    <div class="f-t-content">
                        <img src="../img/foot1.png" alt="">
                        <span>7天无理由退货</span>
                    </div>
                    <div class="f-t-content">
                        <img src="../img/foot1.png" alt="">
                        <span>7天无理由退货</span>
                    </div>
                    <div class="f-t-content f-t-content-n-border">
                        <img src="../img/foot1.png" alt="">
                        <span>7天无理由退货</span>
                    </div>
                </div>
            </div>
        </div>

查看CSS代码

.footer{
    height: 200px;
    /* background-color: tomato; */
}
.footer .footer-top{
    height: 113px;
    /* background-color: aliceblue; */
    overflow: hidden;
    border-top: 1px solid #ccc;
}
.footer .footer-top .f-t-box{
    width: 1120px;
    height: 53px;
    /* background-color: rgb(30, 160, 160); */
    margin: 0 auto;
    margin-top: 30px;
}
.footer .footer-top .f-t-box .f-t-content{
    width: 279px;
    height: 100%;
    /* background-color: chocolate; */
    /* background-color: #eee; */
    float: left;
    border-right:1px solid #ccc;
    text-align: center;
}
.footer .footer-top .f-t-box .f-t-content img{
    vertical-align: middle;
}
.footer .footer-top .f-t-box .f-t-content span{
    vertical-align: middle;
    margin-left: 10px;
}
.footer .footer-top .f-t-box .f-t-content-n-border{
    width: 280px;
    border: none;
}

二、解决方案

在其父盒子、祖父盒子下都加上overflow:hidden

三、修改后的css代码

.footer{
    height: 200px;
    /* background-color: tomato; */
}
.footer .footer-top{
    height: 113px;
    /* background-color: aliceblue; */
    overflow: hidden;
    border-top: 1px solid #ccc;
}
.footer .footer-top .f-t-box{
    width: 1125px;
    height: 53px;
    /* background-color: rgb(30, 160, 160); */
    margin: 0 auto;
    margin-top: 30px;
    overflow: hidden;
}
.footer .footer-top .f-t-box .f-t-content{
    width: 279px;
    height: 100%;
    /* background-color: chocolate; */
    /* background-color: #eee; */
    float: left;
    border-right:1px solid #ccc;
    text-align: center;
    overflow: hidden;
}
.footer .footer-top .f-t-box .f-t-content img{
    vertical-align: middle;
}
.footer .footer-top .f-t-box .f-t-content span{
    vertical-align: middle;
    margin-left: 10px;
}
.footer .footer-top .f-t-box .f-t-content-n-border{
    /* width: 280px;
    border: none; */
    width: 279px;
    /* height: 100%; */
    border: none;
    float: right;
}

缩放到最最最小值25%以下的时候才会换行,效果已经不错了。
在这里插入图片描述
如果有更好的解决办法,欢迎大家评论区给我留言哦。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

李桥桉

支持一下作者

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值