Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flex 布局学习与总结 #6

Open
sweeetcc opened this issue Oct 9, 2016 · 1 comment
Open

Flex 布局学习与总结 #6

sweeetcc opened this issue Oct 9, 2016 · 1 comment
Assignees
Labels

Comments

@sweeetcc
Copy link
Owner

sweeetcc commented Oct 9, 2016

flex-container


相关属性

一、 弹性元素属性

1. 占地面积相关:

flex 属性是 flex-grow、flex-shrink 和 flex-basis 三个属性的简写。

属性 初始值 作用 备注
flex-grow 0 元素宽度之和不足容器宽度时,元素放大的比例 负值无效
flex-shrink 1 元素宽度之和不足容器宽度时,元素缩小的比例 负值无效
flex-basis auto 元素的初始宽度,若元素宽度之和超过容器宽度时,元素按照flex-basis的比例缩放 若为0,必须带单位
none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]
flex: none;

同:

flex: 0 0 auto;
/* 单个值,不带单位,指的是 flex-grow */
flex: 1;
/* 单个值,带单位,指的是 flex-basis */
flex: 200px;
/* 两个值: flex-grow | flex-basis */
flex: 1 30px;
/* 两个值:flex-grow | flex-shrink */
flex: 1 1;
/* 三个值:flex-grow | flex-shrink | flex-basis */
flex: 2 2 10%;

2. 其他属性:

属性 作用 类别
order 元素在容器中的排列顺序 排列
align-self 元素在容器中的对齐方式,针对单个 对齐

二、弹性容器属性

1. 排列相关:

属性 作用 类别
flex-direction 元素在容器中的排列方向 排列
flex-wrap 元素在容器中的换行效果 排列
flex-flow 前两者的复合属性 排列

2. 对齐相关:

属性 作用 类别
justify-content 元素在容器中的水平对齐 对齐
align-items 元素在容器中的垂直对齐 对齐
align-content 元素为多行时在容器中的整体垂直对齐 对齐

示例:

一、父元素属性

1. flex-direction:

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

flex-direction-1

flex-direction-2

flex-direction-3

flex-direction-4

2. flex-wrap:

flex-wrap-1

flex-wrap-2

flex-wrap-3

3. flex-flow:

flex-flow: <'flex-direction'> || <'flex-wrap'>;

flex-flow

4. justify-content:

justify-content: flex-start | flex-end | center | space-between | space-around;

justify-content-1

justify-content-2

justify-content-3

justify-content-4

justify-content-5

5. align-items:

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

align-items-1

a
lign-items-2

align-items-3

align-items-4

align-items-5

6. align-content:

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

align-content-1

align-content-2

align-content-3

align-content-4

align-content-5

align-content-6

二、 子元素属性:

1. order:

order

2. flex-grow:

flex-grow

3. flex-shrink:

flex-shrink

4. align-self:

align-self

@sweeetcc sweeetcc changed the title hello world Flex 布局学习与总结 Oct 9, 2016
@sweeetcc sweeetcc added the css label Oct 9, 2016
@sweeetcc sweeetcc self-assigned this Oct 29, 2016
@sweeetcc
Copy link
Owner Author

说是总结,就是把所有属性都过了一遍,写 react native 感受颇深,需要用到 flex 的地方有时候概念并不清楚,好啦~ 现在清楚啦,以后多温习~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant