ant-design/components/layout/demo/flex-align.md

52 lines
1.4 KiB
Markdown
Raw Normal View History

2015-06-18 15:26:29 +08:00
# Flex对齐
2015-06-09 22:19:35 +08:00
- order: 5
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
---
2015-10-27 23:52:17 +08:00
````jsx
import { Row, Col } from 'antd';
2015-10-27 23:52:17 +08:00
const DemoBox = React.createClass({
2015-10-27 23:52:17 +08:00
render() {
const { value } = this.props;
const className = `hight-${value}`;
return (
<p className={className}>{this.props.children}</p>
);
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="center" align="top">
2016-02-25 15:53:28 +08:00
<Col span={4}><DemoBox value={100}>.col-4</DemoBox></Col>
<Col span={4}><DemoBox value={50}>.col-4</DemoBox></Col>
<Col span={4}><DemoBox value={120}>.col-4</DemoBox></Col>
<Col span={4}><DemoBox value={80}>.col-4</DemoBox></Col>
2015-10-27 23:52:17 +08:00
</Row>
2015-10-27 23:52:17 +08:00
<p>居中对齐</p>
2015-10-28 17:24:35 +08:00
<Row type="flex" justify="space-around" align="middle">
2016-02-25 15:53:28 +08:00
<Col span={4}><DemoBox value={100}>.col-4</DemoBox></Col>
<Col span={4}><DemoBox value={50}>.col-4</DemoBox></Col>
<Col span={4}><DemoBox value={120}>.col-4</DemoBox></Col>
<Col span={4}><DemoBox value={80}>.col-4</DemoBox></Col>
2015-10-27 23:52:17 +08:00
</Row>
2015-10-27 23:52:17 +08:00
<p>底部对齐</p>
2015-10-28 17:24:35 +08:00
<Row type="flex" justify="space-between" align="bottom">
2016-02-25 15:53:28 +08:00
<Col span={4}><DemoBox value={100}>.col-4</DemoBox></Col>
<Col span={4}><DemoBox value={50}>.col-4</DemoBox></Col>
<Col span={4}><DemoBox value={120}>.col-4</DemoBox></Col>
<Col span={4}><DemoBox value={80}>.col-4</DemoBox></Col>
2015-10-27 23:52:17 +08:00
</Row>
</div>,
mountNode
2015-10-27 23:52:17 +08:00
);
2015-06-09 22:19:35 +08:00
````