Tooltip鼠标hover放上时文字提示

使用content属性来决定hover时的提示信息。

placement属性决定展示效果:

placement属性值为:

                方向-对齐位置

四个方向:topleftrightbottom

三种对齐位置:startend,默认为空。如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>
(0)

相关推荐