您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

flex-wrap 换行

flex-wrap 主要通过在外层容器中设置它里面的子项目是否可以换行。认情况下项目是不换行的。

flex-wrap 规定flex容器是单行或者多行,同时横轴的方向决定了新行堆叠的方向。

认情况下,设置了 display:flex 的容器是不会换行的,这时候如果我们希望它换行就可以通过 flex-wrap设置超出宽度换行,也可以设置它如何换行,既换行之后的排列的方向。

flex-wrap: rap|wrap|wrap-reverse|initial|inherit;

.demo{
    display: flex;
    flex-wrap: wrap;
}
.item{
    width: px;
    height: px;
    line-height: px;
    background: #ccc;
    border-right: px solid #fff;
    text-align: center;
}


<!DOCTYPE html>
<html lang="en">
<head>
    < charset="UTF-8">
    < name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

        .demo{
            display: flex;
            flex-wrap: wrap;
        }
        .item{
            width: px;
            height: px;
            line-height: px;
            background: #ccc;
            border-right: px solid #fff;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="demo">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
        <div class="item">4</div>
    </div>
</body>
</html>
.demo{
    display: flex;
    flex-wrap:  wrap-reverse;
}
.item{
    width: px;
    height: px;
    line-height: px;
    background: #ccc;
    border-right: px solid #fff;
    text-align: center;
}

<!DOCTYPE html>
<html lang="en">
<head>
    < charset="UTF-8">
    < name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

        .demo{
            display: flex;
            flex-wrap: wrap-reverse;
        }
        .item{
            width: px;
            height: px;
            line-height: px;
            background: #ccc;
            border-right: px solid #fff;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="demo">
        <div class="item">1</div>
        <div class="item">2</div>
        <div class="item">3</div>
        <div class="item">4</div>
    </div>
</body>
</html>

flex 弹性盒模型认是不换行的既 rap


联系我
置顶