css让盒子跟随浏览器的大小而自适应

方法就是flex布局和设置宽度百分比

比如下面效果的实现

 代码,根据自己需要进行修改即可

<style>
    * {
        margin: 0;
        padding: 0;
    }

    .boxs {
        display: flex;
    }

    .one {
        display: flex;
        width: 20%;
        height: 30px; 
        background-color: aqua;
    }

    .two {
        width: 60%;
        height: 30px;
        background-color: rgb(0, 255, 102);
    }


    .three {
        width: 20%;
        height: 30px;
        background-color: rgb(236, 185, 19);
    }
    .one1,.one3{
        width: 30%;
        background-color: brown;
        margin-left: 3%;
    }
    .one2{
        width: 30%;
        background-color: blueviolet;
    }
</style>

<body>
    <div class="boxs">
        <div class="one">
            <div class="one1">

            </div>
            <div class="one2"></div>
            <div class="one3"></div>
        </div>
        <div class="two"></div>
        <div class="three"></div>
    </div>
</body>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值