9.6 多行对齐方式

73 阅读1分钟
<!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>
        .parent{
            width: 400px;
            height: 300px;
            background-color: #ccc;
            margin: 0 auto;
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            /* 多行弹性元素对齐方式 align-content
            默认值 stretch 平铺拉伸占满父容器高度 前提取消高度
            flex-start 多行起点对齐
            flex-end 多行弹性元素终点对齐
            center 多行弹性元素居中对齐
            space-around
            space-evenly
            space-between
            */
            /* align-content: stretch; */

            align-content: flex-end;
        }
        .parent>div{
            width: 80px;
            height: 50px;
            color: white;
        }
    </style>
</head>
<body>
    <div class="parent">
        <div class="div1" style="background-color: red;">弹性元素1</div>
        <div class="div2" style="background-color: green;">弹性元素2</div>
        <div class="div3" style="background-color: blue;">弹性元素3</div>
        <div class="div1" style="background-color: red;">弹性元素1</div>
        <div class="div2" style="background-color: green;">弹性元素2</div>
        <div class="div3" style="background-color: blue;">弹性元素3</div>
        <div class="div1" style="background-color: red;">弹性元素1</div>
        <div class="div2" style="background-color: green;">弹性元素2</div>
        <div class="div3" style="background-color: blue;">弹性元素3</div>
        <div class="div1" style="background-color: red;">弹性元素1</div>
        <div class="div2" style="background-color: green;">弹性元素2</div>
        <div class="div3" style="background-color: blue;">弹性元素3</div>
    </div>
</body>
</html>