web前端|html教程
a标签,title提示,tooltip
web前端-html教程
简介
php星座测算源码,vscode读取实时数据,ubuntu系统刷新,tomcat老是闪退,php爬虫算法,php跳转到当前页面,贾汪区seo需要多少钱,php完整网站案例,微计算机 模板lzw
用简单的jquery+CSS创建自定义的a标签title提示,用来代替浏览器默认行为。如图:
二人棋牌游戏源码,ubuntu中运行QT,人机识别预防爬虫,质保php,google seo算法lzw
Javascript代码
医疗咨询网站源码,vscode最美文档,Ubuntu磁盘转换,cmd怎样打开tomcat,execjs爬虫,php两个数组并集,怎么快速收录seo 推广,手机自适应网站建设维护,web网页主题模板lzw
复制代码代码如下:
$(function() {
$("a[title]").each(function() {
var a = $(this);
var title = a.attr( itle);
if (title == undefined || title == "") return;
a.data( itle, title)
.removeAttr( itle)
.hover(
function () {
var offset = a.offset();
$("
“).appendTo($(“body”)).html(title).css({ top: offset.top + a.outerHeight() + 10, left: offset.left + a.outerWidth() + 1 }).fadeIn(function () {
var pop = $(this);
setTimeout(function () { pop.remove(); }, pop.text().length*80);
});
},
function() { $(“#anchortitlecontainer”).remove(); }
);
});
}); 别忘记引用JQuery。
代码中setTimeout(function () { pop.remove(); }, pop.text().length*80);是根据title长度计算提示时间,用来防止太短的title提示过长或太长的title提示过短。
CSS代码
复制代码代码如下:
#anchortitlecontainer {
position: absolute;
z-index: 5999;
border: solid 1px #315B6C;
padding: 5px;
color: #315B6C;
background: none repeat scroll 0 0 #FFFFFF;
border-radius: 5px;
display: none;
}
#anchortitlecontainer:before {
position: absolute;
bottom: auto;
left: -1px;
top: -15px;
border-color: transparent transparent transparent #315B6C;
border-style: solid;
border-width: 15px;
content: “”;
display: block;
width: 0;
}
#anchortitlecontainer:after {
position: absolute;
bottom: auto;
left: 0px;
top: -13px;
border-color: transparent transparent transparent #FFFFFF;
border-style: solid;
border-width: 15px;
content: “”;
display: block;
width: 0;
} 使用一些CSS3的特性,回避使用图片。
不是CSS高手,调出这个样式着实花了一些时间,如果有人能用上,那就是我的荣幸了。:)