zoukankan      html  css  js  c++  java
  • display:flex实践加感悟

    • flex-direction 主轴方向,row横着左到右,column竖着上到下。row-reverse,row-reverse.
    • flex-wrap wrap换行,nowrap不换行,wrap-reverse
    • flex-flow
    • justify-content 主轴对齐 flex-start flex-end center     多子节点 space-between space-around
    • align-content 多根轴线在交叉轴方向对齐 同上
    • align-items   交叉轴对齐(垂直移动主轴)flex-start  flex-end  center  baseline(第一行文字基线)  stretch(充满容器高度)
    • flex属性是flex-growflex-shrink 和 flex-basis的简写,默认值为0(有无多余空间也不改变) 1(根据多余空间等比放大或缩小) auto。前两个属性可选。

    • align-self 单单拎出来与众不同设置布局。   

    实践

    <div class="box">
        <span class="item" ></span>
    </div>
    .box{
    display:flex;
    }

    .box{
    display:flex;
    justify-content:center;//主轴上居中
    }

    要记住,所有的属性都是在容器里设置。

    .box{
    display:flex;
    justify-content:flex-end;
    }

    .box{
    display:flex;
    align-content:center;
    }

    .box{
    display:flex;
    justify-content:center;
    align-items:center;
    }

    .box{
    display:flex;
    justify-content:center;
    align-items:flex-end;
    }

                                    双项目(space-between和space-around)

    <div class="box">
        <span class="item"></span>
        <span class="item"></span>
    </div>
    .box{
    display:flex;
    flex-direction:column;
    justify-content:space-between;
    align-items:center;
    }

     当flex-direction:column,相当于页面向右旋转90度;再向右镜像之后的主轴和交叉轴再布局。

                              单独拎出来与众不同

    <div class="box">
        <span class="item"></span>
        <span class="item"></span>
        <span class="item"></span>
    </div>
    .box{
    display:flex;
    }
    .item:nth-child(2){
    align-self:center;
    }
    .item:nth-child(3){
    align-self:flex-end;
    }

    //align-self相当于摆脱对父元素中align-items属性的继承

     

    <div class="box">
        <span class="item"></span>
        <span class="item"></span>
        <span class="item"></span>
        <span class="item"></span>
    </div>
    .box{
    display:flex;
    flex-wrap:wrap;
    align-content:space-between;
    justify-content:flex-end;
    }

    <div class="box">
        <div class="row">
            <span class="item"></span>
            <span class="item"></span>
            <span class="item"></span>
        </div>
        <div class="row">
            <span class="item"></span>
            <span class="item"></span>
        </div>
        <div class="row">
             <span class="item"></span>
        </div>
    </div>
    .box{
    display:flex;
    flex-wrap:wrap;
    }
    .row{
    flex-basis:100%;//该行占据主轴100%,也就是占整行
    display:flex;
    }
    .row:ntn-child(2){
    justify-content:space-between;
    }
    .row:ntn-child(3){
    justify-content:center;
    }
  • 相关阅读:
    数据预处理
    数据挖掘-聚类分析
    数据挖掘分类--判别式模型 ----支持向量机
    神经网络
    数据挖掘-贝叶斯定理
    数据挖掘之分类和预测
    关于stm32的IO口的封装
    星际炸弹——炸弹爆炸时间计算
    共阳极数码管三极管驱动
    自定义的TIME.H头文件
  • 原文地址:https://www.cnblogs.com/vitabebeauty/p/6752028.html
Copyright © 2011-2022 走看看