美文网首页
flex 布局 -- flex 相关属性

flex 布局 -- flex 相关属性

作者: 林键燃 | 来源:发表于2018-11-02 16:40 被阅读19次

flex

.parent {
    display: flex;
}

直接子元素中的块级元素不再霸道的占据一行,并且高度自动等于父元素的高度。

flex-direction

.parent {
    display: flex;
    flex-direction: row; // [row(default), column, row-reverse, column-reverse]
}

justify-content

.parent {
    display: flex;
    justify-content: center; // [center, flex-start(default), flex-end, space-between, space-around]
}

align-items

.parent {
    display: flex;
    align-items: center; // [center, flex-start, flex-end, stretch(default), baseline]
}

flex-wrap

flex-items 超出 flex-container 时是否换行

.parent {
    display: flex;
    flex-wrap: wrap; // [nowrap(default), wrap, warp-reverse]
}

flex-shrink

.flex-child {
    flex-shrink: 1; // [1(default), 正整数],数字越大收缩越多
}

flex-grow (the opposite of flex-shrink)

.flex-child {
    flex-grow: 1; // [正整数],数字越大增大越多
}

flex-basis

用于在 flex-shrink 或 flex-grow 之前初始化 flex item 的尺寸,单位是 px、em、% 等长度单位。

当 flex-item 的宽度大于 flex-basis 设定的值时,当 flex-item 的宽度持续增大,将会以 flex-grow 设定的值去作为增大速度。同理,减小时,使用 flex-shrink 设定的值作为缩小的速度。

.flex-child-1 {
    flex-basis: 10em;
}
.flex-child-2 {
    flex-basis: 10px;
}

flex shorthand

.flex-child {
    flex-grow: 2;
    flex-shrink: 2;
    flex-basis: 10em;
}
=>
.flex-child {
    flex: 2 2 10em;
}

order

这个属性告诉 CSS 我们的 flex-item 在 flex-container 中应该排在哪个位置,它的属性值是整数(负数,0,正数)数字越小排越前。

.flex-child-1 {
    order: 2;
}

.flex-child-2 {
    order: 1;
}

align-self

使用在 flex-item 上的属性,作用和 align-items 类似。是解决 float,clear 和 vertical-align 等 CSS 属性对 flex item 不起作用的技术方案。

.flex-child {
    align-self: center; // [center, flex-start, flex-end, stretch, baseline]
}

相关文章

  • Flex布局

    flex布局前提条件--display: flex(react native 不用设置) 与flex布局相关的属性...

  • css-cmd

    flex布局详解 align-content (底部可以测试flex相关属性)

  • flex详解

    flex概念 flex布局是块级元素;inline-flex是行内元素不会换行 flex相关属性 flex-dir...

  • React Native 页面布局简介

    本文主要讲解与flex布局相关的属性,包括flex,flexDirection,alignItems,justif...

  • React Native 页面布局

    本文主要讲解与flex布局相关的属性,包括flex,flexDirection,alignItems,justif...

  • flex 布局 -- flex 相关属性

    flex 直接子元素中的块级元素不再霸道的占据一行,并且高度自动等于父元素的高度。 flex-direction ...

  • 小程序页面布局样式元素总结

    1:Flex布局 Flex布局如图1所示 1.1 Flex容器属性 1.2 Flex容器内元素属性 align如果...

  • flex 布局 教程笔记

    flex 布局 容器属性flex-flow [flex-direction][flex-...

  • css笔记-6/flex之前的布局

    flex布局 flex之前的布局 flex之后 基本概念 flex container的六个属性 flex ite...

  • 2018-12-25,flex布局

    flex布局的属性: flex-container的属性有flex-direction, flex-wrap, j...

网友评论

      本文标题:flex 布局 -- flex 相关属性

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