最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于JavaScript實(shí)現(xiàn)鼠標(biāo)懸浮彈出跟隨鼠標(biāo)移動(dòng)的帶箭頭的信息層

 更新時(shí)間:2016年01月18日 09:06:39   投稿:mrr  
這篇文章主要介紹了基于JavaScript實(shí)現(xiàn)鼠標(biāo)懸浮彈出跟隨鼠標(biāo)移動(dòng)的帶箭頭的信息層 的相關(guān)資料,需要的朋友可以參考下

很多網(wǎng)站,當(dāng)鼠標(biāo)懸浮在一個(gè)元素上的時(shí)候能夠彈出一個(gè)信息說明層,并且此層能夠跟隨鼠標(biāo)移動(dòng),同時(shí)彈出的層帶有箭頭,此箭頭指向鼠標(biāo)懸浮的元素,下面就通過實(shí)例代碼簡(jiǎn)單介紹一下如何實(shí)現(xiàn)此效果。
代碼實(shí)例如下:

<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="http://www.fzitv.net/" />
<title>腳本之家</title>
<style type="text/css">
#content
{
width:100px;
height:100px;
background:green;
position:relative;
margin:100px;
}
#inform
{
width:200px;
height:200px;
border:1px solid #ccc;
background:white;
display:none;
position:absolute;
}
#inform span
{
width:0px;
height:0px;
border-width:10px;
border-style:none solid solid none;
position:absolute;
}
#inform .tb-border
{
left:-10px;
border-color:transparent #ccc transparent transparent;
top:-1px;
}
#inform .tb-background
{
left:-9px;
border-color:transparent white transparent transparent;
}
</style>
<script type="text/javascript">
window.onload=function()
{
var content=document.getElementById("content");
var inform=document.getElementById("inform");
content.onmouseover=function(ev)
{
var ev=ev||event;
inform.style.display="block";
inform.style.left=(ev.clientX-this.offsetLeft+20)+"px";
inform.style.top=(ev.clientY-this.offsetTop-20)+"px";
}
content.onmousemove=function(ev)
{
var ev=ev||event;
inform.style.left=(ev.clientX-this.offsetLeft+20)+"px";
inform.style.top=(ev.clientY-this.offsetTop-10)+"px";
}
content.onmouseout=function(ev){inform.style.display="none";}
}
</script>
</head>
<body>
<div id="content">
<div id="inform">
<span class="tb-border"></span>
<span class="tb-background"></span>
</div>
</div>
</body>
</html>

以上代碼實(shí)現(xiàn)了我們的要求,當(dāng)鼠標(biāo)放在div中的時(shí)候能夠彈出一個(gè)信息層,并且能夠跟隨鼠標(biāo)移動(dòng),彈出層的帶有指示的箭頭,代碼非常的簡(jiǎn)單這里就不多介紹了,如有任何疑問可以跟帖留言或者參閱相關(guān)閱讀。

相關(guān)文章

最新評(píng)論

肇源县| 如皋市| 通州市| 大冶市| 化德县| 桑植县| 崇义县| 六盘水市| 张家川| 潞城市| 大姚县| 东莞市| 玉溪市| 桑日县| 南和县| 上林县| 镇江市| 博爱县| 彝良县| 永康市| 常熟市| 崇义县| 迭部县| 泾川县| 张掖市| 孝感市| 太仓市| 阳春市| 新昌县| 霍州市| 巩留县| 无为县| 元阳县| 阿拉善左旗| 青州市| 正定县| 罗甸县| 延庆县| 双鸭山市| 奉节县| 龙游县|