flex-direction

2020-10-28 10:19:06 浏览数 (1)

代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
        }
        ul
        {
            list-style: none;
            width: 600px;
            height: 600px;
            border: 1px solid red;
            margin: 100px auto;
            display: flex;
            flex-direction: column;/*用于修改主轴起点的位置*/
            align-items: center;/*告诉浏览器排版好的伸缩项需要和侧轴的center对齐。*/
        }
        ul>li
        {
            width: 100px;
            height: 100px;
            font-size: 30px;
            background: red;
            line-height: 100px;
            text-align: center;
        }
        ul>li:nth-child(2)
        {
            background: blue;
        }
        ul>li:nth-child(3)
        {
            background: yellow
        }
    </style>
</head>
<body>
<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
</ul>
</body>
</html>

0 人点赞