flex调整主轴/多行排列

本文介绍了如何使用CSS3的flex-direction属性将元素的主轴从水平切换为垂直,以及通过设置flex-wrap为wrap实现多行排列。通过示例代码展示了具体的实现方法。
摘要由CSDN通过智能技术生成

调整主轴:flex-direction: column;

就是把横着的X轴变成竖着

不写了,直接上代码

 <style>
        .box {
            width: 500px;
            height: 500px;
            background-color: pink;
            /* 弹性容器 */
            display: flex;
            /* 主轴默认是X轴 */
            /* flex-direction: row; */
            /* 主轴反方向排列 */
            /* flex-direction: row-reverse; */
            /* 调整主轴,换成Y轴 */
            flex-direction: column;
            /* 调整主轴,换成Y轴反方向排列 */
            /* flex-direction: column-reverse; */
            /* 侧轴居中 */
            align-items: center;
            /* 主轴居中 */
            justify-content: center;
        }

        .box>div {
            width: 200px;
            height: 200px;
            background-color: yellowgreen;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="son">老大</div>
   
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值