Flex 弹性布局

** flex弹性布局**
flex弹性布局,给盒状模型提供最大的灵活性。任何一个盒装模型都可以指定为flex布局。
flex-direction属性

 .z{
            width: 500px;
            height: 500px;
            margin: auto;
            border: 1px solid black;
            display: flex;
            flex-direction: row;

        }
        .z>div{
            width: 100px;
            height: 100px;
            background-color:yellow;
            border: 1px solid red;
            box-sizing: border-box;
        }

dzfd
flex-direction:row-reverse;
flex-direction:row-reverse

flex-direction:column;
flex-direction:column
flex-direction:column-reverse;flex-direction:column-reverse
flex-wrap属性

 .z{
            width: 500px;
            height: 500px;
            margin: auto;
            border: 1px solid black;
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;

        }
        .z>div{
            width: 100px;
            height: 100px;
            background-color:yellow;
            border: 1px solid red;
            box-sizing: border-box;
        }

flex-direction:wrap

flex-wrap:nowrap;
flex-wrap:nowrap
flex-direction:wrap-reverse;
flex-direction:wrap-reverse
justify-content属性

 .z{
            width: 500px;
            height: 500px;
            margin: auto;
            border: 1px solid black;
            display: flex;
            flex-direction: row;
            justify-content: center;

        }
        .z>div{
            width: 100px;
            height: 100px;
            background-color:yellow;
            border: 1px solid red;
            box-sizing: border-box;
        }

fx
justify-content:flex-end;
在这里插入图片描述
justify-content:flex-start;
在这里插入图片描述
justify-content:space-around;
在这里插入图片描述
justify-content:space-between;
在这里插入图片描述

align-items属性

align-items:flex-end;
在这里插入图片描述
align-items:flex-start;
在这里插入图片描述
align-items:center;
在这里插入图片描述

.z{
            width: 500px;
            height: 500px;
            margin: auto;
            border: 1px solid black;
            display: flex;
            flex-direction: row;
            justify-content: space-around;
            align-items:baseline;
            text-align: center;

        }
        .z>div{
            background-color:yellow;
            border: 1px solid red;
            box-sizing: border-box;

        }
        .z>div:nth-child(1){
            width: 100px;
            height: 100px;
            font-size: 10px;
            line-height: 100px;
        }
        .z>div:nth-child(2){
            width: 150px;
            height: 150px;
            font-size: 20px;
            line-height: 150px;


        }
        .z>div:nth-child(3){
            width: 200px;
            height: 250px;
            font-size: 30px;
            line-height: 250px;

        }

在这里插入图片描述
align-content属性只对多根轴线起作用,单根不起作用。

 .z{
            width: 500px;
            height: 500px;
            margin: auto;
            border: 1px solid black;
            display: flex;
            flex-wrap: wrap;
            flex-direction:row;
            align-content: flex-end;

            text-align: center;

        }
        .z>div{
            background-color:yellow;
            border: 1px solid red;
            box-sizing: border-box;

        }
        .z>div:nth-child(1){
            width: 100px;
            height: 100px;
            font-size: 10px;
            line-height: 100px;
        }
        .z>div:nth-child(2){
            width: 150px;
            height: 150px;
            font-size: 20px;
            line-height: 150px;


        }
        .z>div:nth-child(3){
            width: 200px;
            height: 100px;
            font-size: 30px;
            line-height: 100px;

        }
        .z>div:nth-child(4){
            width: 100px;
            height: 100px;
            font-size: 10px;
            line-height: 100px;
        }
        .z>div:nth-child(5){
            width: 150px;
            height: 150px;
            font-size: 20px;
            line-height: 150px;


        }
        .z>div:nth-child(6){
            width: 200px;
            height: 100px;
            font-size: 30px;
            line-height: 100px;

        }
        .z>div:nth-child(7){
            width: 100px;
            height: 100px;
            font-size: 10px;
            line-height: 100px;
        }
        .z>div:nth-child(8){
            width: 150px;
            height: 150px;
            font-size: 20px;
            line-height: 150px;


        }
        .z>div:nth-child(9){
            width: 200px;
            height: 100px;
            font-size: 30px;
            line-height: 100px;
        }


    </style>

在这里插入图片描述
align-content:flex-start;
在这里插入图片描述
align-content:center;
在这里插入图片描述
align-content:space-around;
在这里插入图片描述
align-content:space-between;
在这里插入图片描述
align-content:stretch;
在这里插入图片描述
flex属性-子元素按比例分配

.z{
            width: 500px;
            height: 500px;
            margin: auto;
            border: 1px solid black;
            display: flex;
            flex: 1;
            flex-direction:row;
            text-align: center;

        }
        .z>div{
            background-color:yellow;
            border: 1px solid red;
            box-sizing: border-box;

        }
        .z>div:nth-child(1){
            flex: 1;
            height: 100px;
            font-size: 10px;
            line-height: 100px;
        }
        .z>div:nth-child(2){
           flex: 2;
            height: 150px;
            font-size: 20px;
            line-height: 150px;


        }
        .z>div:nth-child(3){
          flex: 3;
            height: 100px;
            font-size: 30px;
            line-height: 100px;

        }

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值