flex-direction

时间:2022-07-28
本文章向大家介绍flex-direction,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
<!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>