2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 1
|
2016-09-30 14:24:41 +08:00
|
|
|
title:
|
2016-08-08 10:40:02 +08:00
|
|
|
zh-CN: 区块间隔
|
2016-09-30 14:24:41 +08:00
|
|
|
en-US: Grid Gutter
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2016-02-23 17:34:46 +08:00
|
|
|
|
2016-08-08 10:40:02 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2017-07-24 10:12:16 +08:00
|
|
|
栅格常常需要和间隔进行配合,你可以使用 `Row` 的 `gutter` 属性,我们推荐使用 `(16+8n)px` 作为栅格间隔。(n 是自然数)
|
2016-02-23 17:34:46 +08:00
|
|
|
|
2017-11-01 18:33:41 +08:00
|
|
|
如果要支持响应式,可以写成 `{ xs: 8, sm: 16, md: 24, lg: 32 }`。
|
|
|
|
|
2019-09-24 21:44:20 +08:00
|
|
|
如果需要垂直间距,可以写成数组形式 `[水平间距, 垂直间距]` `[16, { xs: 8, sm: 16, md: 24, lg: 32 }]`。
|
|
|
|
|
2019-10-18 18:50:33 +08:00
|
|
|
> 数组形式垂直间距在 `3.24.0` 之后支持。
|
|
|
|
|
2016-08-08 10:40:02 +08:00
|
|
|
## en-US
|
|
|
|
|
2017-07-24 10:12:16 +08:00
|
|
|
You can use the `gutter` property of `Row` as grid spacing, we recommend set it to `(16 + 8n) px`. (`n` stands for natural number.)
|
2016-08-08 10:40:02 +08:00
|
|
|
|
2017-11-01 18:33:41 +08:00
|
|
|
You can set it to a object like `{ xs: 8, sm: 16, md: 24, lg: 32 }` for responsive design.
|
|
|
|
|
2019-09-24 21:44:20 +08:00
|
|
|
You can use a array to set vertical spacing, `[horizontal, vertical]` `[16, { xs: 8, sm: 16, md: 24, lg: 32 }]`.
|
|
|
|
|
2019-10-18 18:50:33 +08:00
|
|
|
> vertical gutter was supported after `3.24.0`.
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
```jsx
|
2020-02-26 21:00:43 +08:00
|
|
|
import { Row, Col, Divider } from 'antd';
|
|
|
|
|
|
|
|
const style = { background: '#0092ff', padding: '8px 0' };
|
2016-02-23 17:34:46 +08:00
|
|
|
|
|
|
|
ReactDOM.render(
|
2020-02-26 21:00:43 +08:00
|
|
|
<>
|
|
|
|
<Divider orientation="left" style={{ color: '#333', fontWeight: 'normal' }}>
|
|
|
|
Horizontal
|
|
|
|
</Divider>
|
2016-02-23 17:34:46 +08:00
|
|
|
<Row gutter={16}>
|
2016-03-10 09:41:51 +08:00
|
|
|
<Col className="gutter-row" span={6}>
|
2020-02-26 21:00:43 +08:00
|
|
|
<div style={style}>col-6</div>
|
2016-02-23 17:34:46 +08:00
|
|
|
</Col>
|
2016-03-10 09:41:51 +08:00
|
|
|
<Col className="gutter-row" span={6}>
|
2020-02-26 21:00:43 +08:00
|
|
|
<div style={style}>col-6</div>
|
2016-02-23 17:34:46 +08:00
|
|
|
</Col>
|
2016-03-10 09:41:51 +08:00
|
|
|
<Col className="gutter-row" span={6}>
|
2020-02-26 21:00:43 +08:00
|
|
|
<div style={style}>col-6</div>
|
2016-02-23 17:34:46 +08:00
|
|
|
</Col>
|
2016-03-10 09:41:51 +08:00
|
|
|
<Col className="gutter-row" span={6}>
|
2020-02-26 21:00:43 +08:00
|
|
|
<div style={style}>col-6</div>
|
2016-02-23 17:34:46 +08:00
|
|
|
</Col>
|
|
|
|
</Row>
|
2020-02-26 21:00:43 +08:00
|
|
|
<Divider orientation="left" style={{ color: '#333', fontWeight: 'normal' }}>
|
|
|
|
Responsive
|
|
|
|
</Divider>
|
|
|
|
<Row gutter={{ xs: 8, sm: 16, md: 24, lg: 32 }}>
|
2019-09-24 21:44:20 +08:00
|
|
|
<Col className="gutter-row" span={6}>
|
2020-02-26 21:00:43 +08:00
|
|
|
<div style={style}>col-6</div>
|
2019-09-24 21:44:20 +08:00
|
|
|
</Col>
|
|
|
|
<Col className="gutter-row" span={6}>
|
2020-02-26 21:00:43 +08:00
|
|
|
<div style={style}>col-6</div>
|
2019-09-24 21:44:20 +08:00
|
|
|
</Col>
|
|
|
|
<Col className="gutter-row" span={6}>
|
2020-02-26 21:00:43 +08:00
|
|
|
<div style={style}>col-6</div>
|
2019-09-24 21:44:20 +08:00
|
|
|
</Col>
|
|
|
|
<Col className="gutter-row" span={6}>
|
2020-02-26 21:00:43 +08:00
|
|
|
<div style={style}>col-6</div>
|
2019-09-24 21:44:20 +08:00
|
|
|
</Col>
|
|
|
|
</Row>
|
2020-02-26 21:00:43 +08:00
|
|
|
<Divider orientation="left" style={{ color: '#333', fontWeight: 'normal' }}>
|
|
|
|
Vertical
|
|
|
|
</Divider>
|
|
|
|
<Row gutter={[16, 24]}>
|
|
|
|
<Col className="gutter-row" span={6}>
|
|
|
|
<div style={style}>col-6</div>
|
|
|
|
</Col>
|
|
|
|
<Col className="gutter-row" span={6}>
|
|
|
|
<div style={style}>col-6</div>
|
|
|
|
</Col>
|
|
|
|
<Col className="gutter-row" span={6}>
|
|
|
|
<div style={style}>col-6</div>
|
|
|
|
</Col>
|
|
|
|
<Col className="gutter-row" span={6}>
|
|
|
|
<div style={style}>col-6</div>
|
|
|
|
</Col>
|
|
|
|
<Col className="gutter-row" span={6}>
|
|
|
|
<div style={style}>col-6</div>
|
|
|
|
</Col>
|
|
|
|
<Col className="gutter-row" span={6}>
|
|
|
|
<div style={style}>col-6</div>
|
|
|
|
</Col>
|
|
|
|
<Col className="gutter-row" span={6}>
|
|
|
|
<div style={style}>col-6</div>
|
|
|
|
</Col>
|
|
|
|
<Col className="gutter-row" span={6}>
|
|
|
|
<div style={style}>col-6</div>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</>,
|
2019-05-07 14:57:32 +08:00
|
|
|
mountNode,
|
2018-11-28 15:00:03 +08:00
|
|
|
);
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|
2016-02-23 17:34:46 +08:00
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
```css
|
2016-02-23 17:34:46 +08:00
|
|
|
.gutter-box {
|
2020-02-26 21:00:43 +08:00
|
|
|
padding: 8px 0;
|
2019-05-07 14:57:32 +08:00
|
|
|
background: #00a0e9;
|
2016-02-23 17:34:46 +08:00
|
|
|
}
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|
2019-12-24 15:01:03 +08:00
|
|
|
|
|
|
|
<style>
|
|
|
|
[data-theme="dark"] .gutter-box {
|
|
|
|
background: #028ac8;
|
|
|
|
}
|
|
|
|
</style>
|