美文网首页
【CSS】Flex

【CSS】Flex

作者: 大Q本Q | 来源:发表于2019-06-19 18:07 被阅读0次

Flex弹性布局


父元素

.box{ 
    display:flex;  
    display:-webkit-flex;
}
.boxInline{ 
    display:inline-flex;  
    display:-webkit-inline-flex;
}

主轴对齐 justify-content

flex-start 、flex-end、center、space-between、space-around

justify-content : center; 

交叉轴对齐 align-items

flex-start、flex-end、center、baseline、stretch

align-items: center;

多轴对齐 align-content

flex-start、flex-end、center、space-between、space-around、stretch

align-content: center;

排列方向 flex-direction

row、row-reverse、column、column-reverse;

flex-direction : column;

超过容器,折行 flex-wrap

nowrap、wrap、wrap-reverse;

flex-wrap : wrap;

缩写direction/wrap

flex-flow : flex-dirction || flex-wrap

子元素

初始尺寸 flex-basis

flex-basis: 100;  // 默认:auto

空间剩余 比例分配;若0,则不分配 flex-grow

flex-grow:3;  /* 默认:0 */

空格不足,比例缩小;若0,则不缩小 flex-shrink

flex-shrink:3;    /* 默认:1 */

该子元素的对齐方式 align-self

auto、flex-start、flex-end、center、baseline、stretch

align-self: flex-end;

排序,数值小的排前面 order

order: <integer>;

order:3;

缩写

flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]

兼容

.box{
    display: -webkit-box;       /* 老版本语法: Safari, iOS, Android browser, older WebKit browsers. */
    display: -moz-box;       /* 老版本语法: Firefox (buggy) */
    display: -ms-flexbox;       /* 混合版本语法: IE 10 */   
    display: -webkit-flex;      /* 新版本语法: Chrome 21+ */
    display: flex;           /* 新版本语法: Opera 12.1, Firefox 22+ */
 }

.flex1 {       
    -webkit-box-flex: 1         /* OLD - iOS 6-, Safari 3.1-6 */
    -moz-box-flex: 1;            /* Chrome */  
    -webkit-flex: 1;         /* Chrome */  
    -ms-flex: 1                 /* IE 10 */  
    flex: 1;                        /* NEW, Spec - Opera 12.1, Firefox 20+ */
        
}

示例

ul{
    display: flex;
    flex-wrap: wrap;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
}

li{
    flex-basis: 100px;
}

li.li-1{
    order: 2;
    flex-grow: 1;
    flex-shrink: 1;
    align-self: flex-start;
}
li.li-2{
    order: 1;
    flex-grow: 2;
    flex-shrink: 3;
    align-self: center;
}
li.li-3{
    order: 3;
    flex-grow: 0;
    flex-shrink: 0;
    align-items: flex-end;
}

相关文章

  • css flex布局详解

    css flex布局详解 css flex布局详解1css flex布局详解2

  • html编程技巧

    字体外部描边 Css 基于flex布局的盒子上下居中 Css 基于flex布局的盒子左右居中 Css 基于flex...

  • flex布局

    /*! https://github.com/lzxb/flex.css */ [flex], [flex] > ...

  • 小程序CSS知识点

    一、flex布局Flex 布局教程:语法篇Flex 布局教程:实例篇 二、CSS position 属性总结CSS...

  • css flex

    css flex布局 采用 Flex 布局的元素,称为 Flex 容器(flex container),简称“容器...

  • flex.css:移动端 flex 布局

    flex.css 快速布局 什么是 flex.css css3 flex 布局相信很多人已经听说过甚至已经在开发中...

  • css

    css基础css选择器css常见样式1css常见样式2CSS布局上CSS布局下flex布局塔防小游戏flex布局青...

  • CSS 圣杯布局(左右固定、中间自适应)

    CSS 圣杯布局 flex 布局(推荐) 定位布局(推荐) css3 calc布局(影响性能,不推荐) flex:...

  • 关于Flex的使用

    基本概念 css3 中Flex意为‘弹性布局’,采用css3 Flex布局的元素,称为Flex容器,它的所有子元素...

  • 阮一峰CSS flex -弹性布局

    阮一峰CSS flex 布局教程 Flex 布局教程:实例篇

网友评论

      本文标题:【CSS】Flex

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