css3伸缩盒模型(二)

5.主轴对齐方式

所需属性:justify-content

常用值如下:

1.flex-start 主轴的起始位置。

2.flex-end 主轴的结束位置。

 

3.center 中间对齐。

4.space-around 项目均匀分布在一行,项目与项目之间的距离是相等的,且是项目边缘的2倍。

5. space-between 项目均匀分布在一行,项目与项目之间的距离是相等的,与项目边缘没有距离

6.space-evenly 项目均匀分布在一行 

源码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .outer{
            width: 1000px;
            height: 600px;
            background-color: aquamarine;
            margin: 0 auto;
            display: flex;
            /* 默认主轴方向,水平从左往右 */
            flex-direction: row;
            flex-wrap: nowrap;
            /* 主轴对齐方式 --主轴的起始位置*/
            /* justify-content: flex-start; */
            /* 主轴对齐方式 --主轴的结束位置*/
            /* justify-content: flex-end; */
            /* 主轴对齐方式 --中间对齐*/
            /* justify-content: center; */
            /*  主轴对齐方式 --项目均匀分布在一行,项目与项目之间的距离是相等的,与项目边缘没有距离*/
            /* justify-content: space-around; */
            /*  主轴对齐方式 --项目均匀分布在一行 */
            justify-content: space-evenly;

        }
        .inner{
            width: 200px;
            height: 200px;
            background-color: cadetblue;
            border: 1px solid black;
            box-sizing: border-box;
        }
    </style>
</head>
<body>
    <div class="outer">
        <div class="inner">1</div>
        <div class="inner">2</div>
        <div class="inner">3</div>
    </div>
   
</body>
</html>

6.侧轴对齐 

(1)一行

所需属性:align-items

常用值如下:

1.flex-start 侧轴的起始位置。

2.flex-end 侧轴的结束位置。 

 3.center 中间对齐

4.stretch 拉伸到整个父容器,(前提是伸缩项目不能给高度)默认 

5.baseline 侧轴对齐方式 --伸缩项目的第一行文字的基线对齐*/

 源码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .outer{
            width: 1000px;
            height: 600px;
            background-color: aquamarine;
            margin: 0 auto;
            display: flex;
            /* 默认主轴方向,水平从左往右 */
            flex-direction: row;
            flex-wrap: nowrap;
            /* 主轴对齐方式 --主轴的起始位置*/
            /* justify-content: flex-start; */
            /* 主轴对齐方式 --主轴的结束位置*/
            /* justify-content: flex-end; */
            /* 主轴对齐方式 --中间对齐*/
            /* justify-content: center; */
            /* 主轴对齐方式 --项目均匀分布在一行,项目与项目之间的距离是相等的,且是项目边缘的2倍 */
            /* justify-content: space-around; */
             /* 主轴对齐方式 --项目均匀分布在一行,项目与项目之间的距离是相等的,与项目边缘没有距离 */
            /* justify-content:space-between ; */
            /*  主轴对齐方式 --项目均匀分布在一行 */
            /* justify-content: space-evenly; */

        }
        .inner{
            width: 200px;
            height: 200px;
            background-color: cadetblue;
            border: 1px solid black;
            box-sizing: border-box;
        }
    </style>
</head>
<body>
    <div class="outer">
        <div class="inner">1</div>
        <div class="inner">2</div>
        <div class="inner">3</div>
    </div>
   
</body>
</html>

(2)多行

 所需属性:align-content

常用值如下:

.flex-start 侧轴的起始位置。

2.flex-end 侧轴的结束位置。 

 3.center 中间对齐。

4.space-around 项目均匀分布在一行,项目与项目之间的距离是相等的,且是项目边缘的2倍。

 

5.space-between  项目均匀分布在一行,项目与项目之间的距离是相等的,与项目边缘没有距离

6.space-evenly 项目均匀分布

7..stretch 拉伸,(前提是伸缩项目不能给高度)默认

  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值