美文网首页
flex布局

flex布局

作者: 清风昙 | 来源:发表于2022-11-11 21:45 被阅读0次
    1.flex-direction属性

    flex-direction属性决定主轴的方向

    flex-direction: row | row-reverse | column | column-reverse
    

    row(默认值):主轴为水平方向,起点在左端
    row-reverse:主轴为水平方向,起点在右端
    column:主轴为垂直方向,起点在上方
    column-reverse:主轴为垂直方向,起点在下方

    2.flex-wrap属性

    flex-wrap决定是否换行

    flex-wrap: nowrap | wrap | wrap-reverse
    

    nowrap(默认):不换行
    wrap:换行,第一行在上方
    wrap-reverse:换行,第一行在下方

    3.flex-flow属性

    flex-flow属性是flex-direction和flex-wrap的简写形式,默认值为row nowrap

    flex-flow: <flex-direction> || <flex-wrap>
    
    4.justify-content属性
    justify-content: flex-start | flex-end | center | space-between | space-around
    

    flex-start(默认值):左对齐
    flex-end:右对齐
    center: 居中
    space-between:两端对齐,项目之间的间隔都相同
    space-around:每个项目两侧的间距相同(项目之间的间隔比项目与边框的间隔大一倍)

    5.align-items属性

    align-items属性定义项目在交叉轴上如何对齐

    align-items: flex-start | flex-end | center | baseline | stretch
    

    stretch(默认值):如果项目未设置高度或设为auto,将占满整个容器的高度
    flex-start:交叉轴的起点对齐
    flex-end:交叉轴的终点对齐
    center:交叉轴的中点对齐
    baseline:项目的第一行文字的基线对齐

    6.align-content属性

    align-content属性定义了多根轴线的对齐方式,如果项目只有一根轴线,该属性不起作用

    align-content: stretch | flex-start | flex-end | center | space-between | space-around
    

    stretch(默认值):轴线沾满整个交叉轴
    flex-start:与交叉轴的起点对齐
    flex-end:与交叉轴的终点对齐
    center:与交叉轴的中点对齐
    space-between:与交叉轴两端对齐,轴线之间的间隔平均分布
    space-around:每根轴线两侧的间距相等(轴线之间的间距比轴线与边框的间隔大一倍)

    相关文章

      网友评论

          本文标题:flex布局

          本文链接:https://www.haomeiwen.com/subject/unccxdtx.html