亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

用簡(jiǎn)單的jquery+CSS創(chuàng)建自定義的a標(biāo)簽title提示tooltip

  發(fā)布時(shí)間:2014-05-21 15:12:44   作者:佚名   我要評(píng)論
這篇文章主要介紹了用簡(jiǎn)單的jquery+CSS創(chuàng)建自定義的a標(biāo)簽title提示tooltip,需要的朋友可以參考下
簡(jiǎn)介

用簡(jiǎn)單的jquery+CSS創(chuàng)建自定義的a標(biāo)簽title提示,用來(lái)代替瀏覽器默認(rèn)行為。如圖:

 

Javascript代碼

復(fù)制代碼
代碼如下:

</pre><pre name="code" class="javascript">$(function() {
$("a[title]").each(function() {
var a = $(this);
var title = a.attr('title');
if (title == undefined || title == "") return;
a.data('title', title)
.removeAttr('title')
.hover(
function () {
var offset = a.offset();
$("<div id=\"anchortitlecontainer\"></div>").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);是根據(jù)title長(zhǎng)度計(jì)算提示時(shí)間,用來(lái)防止太短的title提示過(guò)長(zhǎng)或太長(zhǎng)的title提示過(guò)短。

CSS代碼

復(fù)制代碼
代碼如下:

#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高手,調(diào)出這個(gè)樣式著實(shí)花了一些時(shí)間,如果有人能用上,那就是我的榮幸了。:)

相關(guān)文章

最新評(píng)論