该属性是控制子项在侧轴(默认是y轴)上的排列方式在子项为单项的时候使用

    属性值 说明
    flex-start 从上到下
    flex-end 从下到上
    center 挤在一块居中(垂直居中)
    stretch(了解) 拉伸(默认值)
    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Document</title>
    8. <style>
    9. div {
    10. display: flex;
    11. width: 500px;
    12. height: 500px;
    13. background-color: blue;
    14. flex-direction: row;
    15. justify-content: center;
    16. align-items: center;
    17. }
    18. div span {
    19. width: 100px;
    20. height: 100px;
    21. margin: 10px;
    22. background-color: red;
    23. }
    24. </style>
    25. </head>
    26. <body>
    27. <div>
    28. <span>1</span>
    29. <span>2</span>
    30. <span>3</span>
    31. </div>
    32. </body>
    33. </html>

    image.png