2015-06-18 15:26:29 +08:00
|
|
|
# Flex布局
|
2015-06-09 22:19:35 +08:00
|
|
|
|
2015-10-28 20:55:49 +08:00
|
|
|
- order: 4
|
2015-06-09 22:19:35 +08:00
|
|
|
|
2015-06-15 17:46:42 +08:00
|
|
|
Flex 布局基础。
|
2015-06-09 22:19:35 +08:00
|
|
|
|
|
|
|
使用 `row-flex` 定义 `flex` 布局,其子元素根据不同的值 `start`,`center`,`end`,`space-between`,`space-around`,分别定义其在父节点里面的排版方式。
|
|
|
|
|
|
|
|
---
|
|
|
|
|
2015-10-27 23:52:17 +08:00
|
|
|
````jsx
|
2015-10-28 20:55:49 +08:00
|
|
|
import { Row, Col } from 'antd';
|
2015-10-27 23:52:17 +08:00
|
|
|
|
|
|
|
ReactDOM.render(
|
|
|
|
<div>
|
|
|
|
<p>子元素居左排列</p>
|
2015-10-28 17:24:35 +08:00
|
|
|
<Row type="flex" justify="start">
|
2016-02-25 15:53:28 +08:00
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
2015-10-27 23:52:17 +08:00
|
|
|
</Row>
|
2015-10-28 20:55:49 +08:00
|
|
|
|
2015-10-27 23:52:17 +08:00
|
|
|
<p>子元素居中排列</p>
|
2015-10-28 17:24:35 +08:00
|
|
|
<Row type="flex" justify="center">
|
2016-02-25 15:53:28 +08:00
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
2015-10-27 23:52:17 +08:00
|
|
|
</Row>
|
|
|
|
|
|
|
|
<p>子元素居右排列</p>
|
2015-10-28 17:24:35 +08:00
|
|
|
<Row type="flex" justify="end">
|
2016-02-25 15:53:28 +08:00
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
2015-10-27 23:52:17 +08:00
|
|
|
</Row>
|
|
|
|
|
|
|
|
<p>子元素等宽排列</p>
|
2015-10-28 17:24:35 +08:00
|
|
|
<Row type="flex" justify="space-between">
|
2016-02-25 15:53:28 +08:00
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
2015-10-27 23:52:17 +08:00
|
|
|
</Row>
|
|
|
|
|
|
|
|
<p>子元素分散对齐</p>
|
2015-10-28 17:24:35 +08:00
|
|
|
<Row type="flex" justify="space-around">
|
2016-02-25 15:53:28 +08:00
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
|
|
|
<Col span={4}>.col-4</Col>
|
2015-10-27 23:52:17 +08:00
|
|
|
</Row>
|
|
|
|
</div>,
|
2015-12-29 12:08:58 +08:00
|
|
|
mountNode
|
2015-11-25 17:35:49 +08:00
|
|
|
);
|
2015-06-09 22:19:35 +08:00
|
|
|
````
|