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

101 lines
2.6 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.
```tsx
2022-05-23 14:37:16 +08:00
import { Button, Popover } from 'antd';
import React from 'react';
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;
const App: React.FC = () => (
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>
2019-05-07 14:57:32 +08:00
<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>
</div>
2018-11-28 15:00:03 +08:00
);
export default App;
2019-05-07 14:57:32 +08:00
```
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;
}
.code-box-demo .ant-btn-rtl {
margin-right: 0;
margin-left: 8px;
margin-bottom: 8px;
}
2016-10-07 15:20:10 +08:00
#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>