CSS-多列布局2-断行

1、column-break-inside

auto :既不强迫也不禁止在元素内部断行并产生新列
avoid:避免在元素内部断行并产生新列

2、实例效果

源代码:

 <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS多列断行</title>
    <style type="text/css">
    .container{
        border: 1px solid gray;
        columns: 3;
        width: 500px;
        padding: 20px;
    }
    .box{
        width: 89px;
        height: 89px;
        border: 1px solid red;
        margin: 5px;
    }
    .container1{
        border: 1px solid gray;
        columns: 3;
        width: 500px;
        padding: 20px;
        margin-top: 10px;
    }
    .box1{
        width: 89px;
        height: 89px;
        -webkit-column-break-inside:avoid;
        column-break-inside:avoid;
        border: 1px solid red;
        margin: 5px;
    }
    </style>
</head>
<body>
    <p>column-break-inside:默认值</p>
    <div class="container">
        <div class="box">1</div>
        <div class="box">2</div>
        <div class="box">3</div>
        <div class="box">4</div>
        <div class="box">5</div>
    </div>
    <p>-webkit-column-break-inside:avoid;
        column-break-inside:avoid;</p>
    <div class="container1">
        <div class="box1">1</div>
        <div class="box1">2</div>
        <div class="box1">3</div>
        <div class="box1">4</div>
        <div class="box1">5</div>
    </div>
</body>
</html>

运行效果:

image.png
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值