You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.0 KiB

---
order: 1
7 years ago
title:
zh-CN: 位置
en-US: Placement
---
10 years ago
## zh-CN
9 years ago
位置有 12 个方向。
10 years ago
7 years ago
## en-US
The ToolTip has 12 placements choice.
````jsx
7 years ago
import { Tooltip, Button } from 'antd';
const text = <span>prompt text</span>;
10 years ago
7 years ago
const buttonWidth = 70;
9 years ago
ReactDOM.render(
7 years ago
<div className="demo">
<div style={{ marginLeft: buttonWidth, whiteSpace: 'nowrap' }}>
<Tooltip placement="topLeft" title={text}>
7 years ago
<Button>TL</Button>
</Tooltip>
<Tooltip placement="top" title={text}>
7 years ago
<Button>Top</Button>
</Tooltip>
<Tooltip placement="topRight" title={text}>
7 years ago
<Button>TR</Button>
</Tooltip>
</div>
7 years ago
<div style={{ width: buttonWidth, float: 'left' }}>
<Tooltip placement="leftTop" title={text}>
7 years ago
<Button>LT</Button>
</Tooltip>
<Tooltip placement="left" title={text}>
7 years ago
<Button>Left</Button>
</Tooltip>
<Tooltip placement="leftBottom" title={text}>
7 years ago
<Button>LB</Button>
</Tooltip>
</div>
7 years ago
<div style={{ width: buttonWidth, marginLeft: (buttonWidth * 4) + 24 }}>
<Tooltip placement="rightTop" title={text}>
7 years ago
<Button>RT</Button>
</Tooltip>
<Tooltip placement="right" title={text}>
7 years ago
<Button>Right</Button>
</Tooltip>
<Tooltip placement="rightBottom" title={text}>
7 years ago
<Button>RB</Button>
</Tooltip>
</div>
7 years ago
<div style={{ marginLeft: buttonWidth, clear: 'both', whiteSpace: 'nowrap' }}>
<Tooltip placement="bottomLeft" title={text}>
7 years ago
<Button>BL</Button>
</Tooltip>
<Tooltip placement="bottom" title={text}>
7 years ago
<Button>Bottom</Button>
</Tooltip>
<Tooltip placement="bottomRight" title={text}>
7 years ago
<Button>BR</Button>
</Tooltip>
</div>
</div>,
mountNode
);
10 years ago
````
10 years ago
<style>
7 years ago
.code-box-demo .demo {
overflow: auto;
}
.code-box-demo .ant-btn {
margin-right: 8px;
margin-bottom: 8px;
}
#components-tooltip-demo-placement .ant-btn {
width: 70px;
9 years ago
text-align: center;
7 years ago
padding: 0;
10 years ago
}
</style>