布局的栅格化系统,是基于行(row)和列(col)来定义信息区块的外部框架,以保证页面的每个区域能够稳健地排布起来。
2
const PlaceHolder = ({ children }) => (
3
<div style={{ height: '50px', textAlign: 'center', background: 'papayawhip' }}>{children}</div>
8
<PlaceHolder>col-4</PlaceHolder>
11
<PlaceHolder>col-4</PlaceHolder>
14
<PlaceHolder>col-4</PlaceHolder>
Gutter 用于设置栅格间距,使用数组形式同时设置[水平间距,垂直间距]
2
const PlaceHolder = ({ children }) => (
3
<div style={{ height: '50px', textAlign: 'center', background: 'papayawhip' }}>{children}</div>
6
<Row gutter={[50, 20]}>
8
<PlaceHolder>col-4</PlaceHolder>
11
<PlaceHolder>col-4</PlaceHolder>
14
<PlaceHolder>col-4</PlaceHolder>
多行排列,栅格系统默认当栅格数是十二,当没有自定义栅格数且一行当栅格超过了十二,那么剩余当栅格将会换行排列。
2
const PlaceHolder = ({ children }) => (
3
<div style={{ height: '50px', textAlign: 'center', background: 'papayawhip' }}>{children}</div>
6
<Row gutter={[20, 50]}>
8
<PlaceHolder>col-4</PlaceHolder>
11
<PlaceHolder>col-4</PlaceHolder>
14
<PlaceHolder>col-4</PlaceHolder>
17
<PlaceHolder>col-4</PlaceHolder>
栅格自适应宽度,在一行中,栅格数超过 12 时,剩余栅格占满一行。
2
const PlaceHolder = ({ children }) => (
3
<div style={{ height: '50px', textAlign: 'center', background: 'papayawhip' }}>{children}</div>
8
<PlaceHolder>col-4</PlaceHolder>
11
<PlaceHolder>col-4</PlaceHolder>
14
<PlaceHolder>col-4</PlaceHolder>
17
<PlaceHolder>col-4</PlaceHolder>
通过给 col 组件设置 offset,可以控制栅格偏移的距离。
2
const PlaceHolder = ({ children }) => (
3
<div style={{ height: '50px', textAlign: 'center', background: 'papayawhip' }}>{children}</div>
8
<PlaceHolder>col-3</PlaceHolder>
11
<PlaceHolder>col-3</PlaceHolder>
13
<Col span={3} offset={3}>
14
<PlaceHolder>col-3</PlaceHolder>
默认是十二栅格,通过给 Row 组件设置 columns,可以自定义栅格数。
2
const PlaceHolder = ({ children }) => (
3
<div style={{ height: '50px', textAlign: 'center', background: 'papayawhip' }}>{children}</div>
8
<PlaceHolder>col-12</PlaceHolder>
11
<PlaceHolder>col-6</PlaceHolder>
14
<PlaceHolder>col-6</PlaceHolder>