当前位置:网站首页>tooltips使用教程(鼠标悬停时显示提示)
tooltips使用教程(鼠标悬停时显示提示)
2022-07-31 15:33:00 【滕青山YYDS】
效果
希望鼠标悬停时给出提示,如图:
实战
我们这里使用Bootstrap中的tooltips来实现。
引入css和js文件
引入bootstrap css文件
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
引入js
<script src="js/jquery-2.1.1.min.js"></script> <script src="js/popper.min.js"></script> <script src="js/bootstrap.min.js"></script>
文件下载地址依次为:
https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css
https://code.jquery.com/jquery-3.3.1.slim.min.js
https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js
https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js
使用
在html文件加上下面这块代码
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="top" title="Tooltip on top">
Tooltip on top
</button>
重点是data-toggle
和data-placement
这两个属性。
最后通过下面这块js代码来启用提示:
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
可以看到js代码中是通过data-toggle
属性来选择元素进行展示提示文本的,而data-placement
属性用于设置提示文本的位置,如top\bottom\left\right
。
文档
边栏推荐
猜你喜欢
随机推荐
多主复制的适用场景(1)-多IDC
[CUDA study notes] First acquaintance with CUDA
第二届中国PWA开发者日
thread_local 变量的析构顺序
Oracle动态注册非1521端口
女性服务社群产品设计
update data table update
MySQL database operations
Insert into data table to insert data
WPF项目--控件入门基础用法,必知必会XAML
Delete the disk in good condition (recovery partition)
TRACE32 - SNOOPer-based variable logging
实现防抖与节流函数
RecyclerView的高效使用第一节
复制延迟案例(3)-单调读
【Meetup预告】OpenMLDB+OneFlow:链接特征工程到模型训练,加速机器学习模型开发
数据库的范式(第一范式,第二范式,第三范式,BCNF范式)「建议收藏」
力扣:56. 合并区间
R language moves time series data forward or backward (custom lag or lead period): use the lag function in the dplyr package to move the time series data forward by one day (set the parameter n to a p
R language ggplot2 visualization: use the ggboxplot function of the ggpubr package to visualize the grouped box plot, use the ggpar function to change the graphical parameters (caption, add, modify th