flex布局container:justify-content属性

flex布局container:justify-content属性;

justify-content:

justify-content是决定idems在主轴的对齐方式

        .test{
            height: 400px;
            width: 400px;
            background-color: #f00;
            /* 开启flex布局 */
            display: inline-flex;
            /* justify-content: center; 居中对齐*/
            /* justify-content: flex-start;已start为开始位置进行排列 */
            justify-content: flex-end;/*已end为开始位置进行排列*/
        }
        .box{
            height: 100px;
            width: 100px;
        }
        .box1{
            background-color: #ff0;
        }
        .box2{
            background-color: #0f0;
        }
        .box3{
            background-color: #00f;
        }
    </style>
</head>
<body>
    <div class="test">
        <div class="box1 box">idems1</div>
        <div class="box2 box">idems2</div>
        <div class="box3 box">idens3</div>
    </div>
</body>

代码效果:
在这里插入图片描述
justify-content也可以设置items的中间的排列方式

在这里插   <style>
        .test{
            height: 400px;
            width: 400px;
            background-color: #f00;
            /* 开启flex布局 */
            display: inline-flex;
            /* justify-content: space-between;把主轴的空隙等分在items中间 */
            /* justify-content: space-evenly; 把主轴的空隙等分在items的两边,*/
            justify-content: space-around;/* 把主轴的空隙等分在items的两边,但中间比最两边大两倍*/
        }
        .box{
            height: 100px;
            width: 100px;
        }
        .box1{
            background-color: #ff0;
        }
        .box2{
            background-color: #0f0;
        }
        .box3{
            background-color: #00f;
        }
    </style>
</head>
<body>
    <div class="test">
        <div class="box1 box">idems1</div>
        <div class="box2 box">idems2</div>
        <div class="box3 box">idens3</div>
    </div>
</body>入代码片

代码效果:
在这里插入图片描述
总结:justify-content可以通过一些值更简单,细致的操作里面的items,不用在单独写样式

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值