ant-design/components/popover/demo/placement.md

93 lines
2.5 KiB
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
2016-10-14 21:45:48 +08:00
order: 2
title:
zh-CN: 位置
en-US: Placement
2016-03-31 09:40:55 +08:00
---
2015-06-17 16:58:13 +08:00
## zh-CN
位置有十二个方向。
2015-06-17 16:58:13 +08:00
## en-US
There are 12 `placement` options available.
2017-02-13 10:55:53 +08:00
````jsx
import { Popover, Button } from 'antd';
2016-09-29 13:43:55 +08:00
const text = <span>Title</span>;
const content = (
<div>
2016-09-29 13:43:55 +08:00
<p>Content</p>
<p>Content</p>
</div>
);
2015-06-17 16:58:13 +08:00
2016-10-07 15:20:10 +08:00
const buttonWidth = 70;
ReactDOM.render(
2016-10-07 15:20:10 +08:00
<div className="demo">
<div style={{ marginLeft: buttonWidth, whiteSpace: 'nowrap' }}>
<Popover placement="topLeft" title={text} content={content} trigger="click">
2016-09-29 13:43:55 +08:00
<Button>TL</Button>
</Popover>
<Popover placement="top" title={text} content={content} trigger="click">
2016-09-29 13:43:55 +08:00
<Button>Top</Button>
</Popover>
<Popover placement="topRight" title={text} content={content} trigger="click">
2016-09-29 13:43:55 +08:00
<Button>TR</Button>
</Popover>
</div>
2016-10-07 15:20:10 +08:00
<div style={{ width: buttonWidth, float: 'left' }}>
<Popover placement="leftTop" title={text} content={content} trigger="click">
2016-09-29 13:43:55 +08:00
<Button>LT</Button>
</Popover>
<Popover placement="left" title={text} content={content} trigger="click">
2016-09-29 13:43:55 +08:00
<Button>Left</Button>
</Popover>
<Popover placement="leftBottom" title={text} content={content} trigger="click">
2016-09-29 13:43:55 +08:00
<Button>LB</Button>
</Popover>
</div>
<div style={{ width: buttonWidth, marginLeft: (buttonWidth * 4) + 24 }}>
<Popover placement="rightTop" title={text} content={content} trigger="click">
2016-09-29 13:43:55 +08:00
<Button>RT</Button>
</Popover>
<Popover placement="right" title={text} content={content} trigger="click">
2016-09-29 13:43:55 +08:00
<Button>Right</Button>
</Popover>
<Popover placement="rightBottom" title={text} content={content} trigger="click">
2016-09-29 13:43:55 +08:00
<Button>RB</Button>
</Popover>
</div>
2016-10-07 15:20:10 +08:00
<div style={{ marginLeft: buttonWidth, clear: 'both', whiteSpace: 'nowrap' }}>
<Popover placement="bottomLeft" title={text} content={content} trigger="click">
2016-09-29 13:43:55 +08:00
<Button>BL</Button>
</Popover>
<Popover placement="bottom" title={text} content={content} trigger="click">
2016-09-29 13:43:55 +08:00
<Button>Bottom</Button>
</Popover>
<Popover placement="bottomRight" title={text} content={content} trigger="click">
2016-09-29 13:43:55 +08:00
<Button>BR</Button>
</Popover>
</div>
2018-06-27 15:55:04 +08:00
</div>,
mountNode);
2015-06-17 16:58:13 +08:00
````
<style>
2017-10-16 19:53:46 +08:00
.code-box-demo .demo {
overflow: auto;
}
2015-06-17 16:58:13 +08:00
.code-box-demo .ant-btn {
2016-10-07 15:20:10 +08:00
margin-right: 8px;
margin-bottom: 8px;
}
#components-popover-demo-placement .ant-btn {
width: 70px;
2017-10-16 19:53:46 +08:00
text-align: center;
padding: 0;
2015-06-17 16:58:13 +08:00
}
</style>