使用content
屬性來決定hover
時的提示資訊。
由placement
屬性決定展示效果:
placement
屬性值為:
方向-對齊位置
;
四個方向:top
、left
、right
、bottom
;
三種對齊位置:start
, end
,預設為空。如placement="left-end"
,
則提示資訊出現在目標元素的左側,且提示資訊的底部與目標元素的底部對齊。
1 <div class="box"> 2 <div class="top"> 3 <el-tooltip class="item" effect="dark" content="Top Left 我在上左" placement="top-start"> 4 <el-button>上左</el-button> 5 </el-tooltip> 6 <el-tooltip class="item" effect="dark" content="Top Center 我在正上" placement="top"> 7 <el-button>上邊</el-button> 8 </el-tooltip> 9 <el-tooltip class="item" effect="dark" content="Top Right 我在上右" placement="top-end"> 10 <el-button>上右</el-button> 11 </el-tooltip> 12 </div> 13 <div class="left"> 14 <el-tooltip class="item" effect="dark" content="Left Top 我在左上" placement="left-start"> 15 <el-button>左上</el-button> 16 </el-tooltip> 17 <el-tooltip class="item" effect="dark" content="Left Center 我在左邊" placement="left"> 18 <el-button>左邊</el-button> 19 </el-tooltip> 20 <el-tooltip class="item" effect="dark" content="Left Bottom 我在左下" placement="left-end"> 21 <el-button>左下</el-button> 22 </el-tooltip> 23 </div> 24 25 <div class="right"> 26 <el-tooltip class="item" effect="dark" content="Right Top 我在右上" placement="right-start"> 27 <el-button>右上</el-button> 28 </el-tooltip> 29 <el-tooltip class="item" effect="dark" content="Right Center 我在右邊" placement="right"> 30 <el-button>右邊</el-button> 31 </el-tooltip> 32 <el-tooltip class="item" effect="dark" content="Right Bottom 我在右下" placement="right-end"> 33 <el-button>右下</el-button> 34 </el-tooltip> 35 </div> 36 <div class="bottom"> 37 <el-tooltip class="item" effect="dark" content="Bottom Left 我在下左" placement="bottom-start"> 38 <el-button>下左</el-button> 39 </el-tooltip> 40 <el-tooltip class="item" effect="dark" content="Bottom Center 我在下邊" placement="bottom"> 41 <el-button>下邊</el-button> 42 </el-tooltip> 43 <el-tooltip class="item" effect="dark" content="Bottom Right 我在下右" placement="bottom-end"> 44 <el-button>下右</el-button> 45 </el-tooltip> 46 </div> 47 </div>
1 <style> 2 .box { 3 width: 400px; 4 5 .top { 6 text-align: center; 7 } 8 9 .left { 10 float: left; 11 width: 60px; 12 } 13 14 .right { 15 float: right; 16 width: 60px; 17 } 18 19 .bottom { 20 clear: both; 21 text-align: center; 22 } 23 24 .item { 25 margin: 4px; 26 } 27 28 .left .el-tooltip__popper, 29 .right .el-tooltip__popper { 30 padding: 8px 10px; 31 } 32 } 33 </style>