jquery實(shí)現(xiàn)鼠標(biāo)懸浮彈出氣泡提示框
jquery鼠標(biāo)懸浮彈出氣泡提示框,供大家參考,具體內(nèi)容如下
居中的圖片
代碼
我在網(wǎng)上找了很多例子都是單獨(dú)的一個,所以我修改了jquery的一點(diǎn)代碼,讓它可以在一個頁面上多次使用,原文的地址我沒找到,相信我這個會更好一點(diǎn)。
//別忘了導(dǎo)入js文件!
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>氣泡顯示</title> <script type="text/javascript" src="../js/jquery-1.8.3.js" ></script> <style type="text/css"> .container { margin-top: 130px; } .tip { padding: 8px 12px; width: 140px; display: block; font-size: 16px; color: #fff; font-weight: bold; background: #ED5517; cursor: pointer; margin-left: 400px; align-content: center; margin-top: 20px; margin-bottom: 20px; } .content { position: absolute; display: none; padding: 10px; width: 160px; background: #e0edf7; border-radius: 6px; } .content::before { content: ""; position: relative; top: -20px; left: 10px; width: 0; height: 0; display: block; border-left: 10px solid transparent; border-right: 10px solid transparent; border-bottom: 10px solid #e0edf7; } </style> </head> <body> <div class="container"> <span id="xsztip" class="tip">鼠標(biāo)懸停顯示氣泡</span> <div class="content"> <span>The quick fox jumps over a lazy dog.</span> </div> <span id="xsztip2" class="tip">鼠標(biāo)懸停顯示氣泡</span> <div class="content"> <span>The quick fox jumps over a lazy dog.</span> </div> <span id="xsztip3" class="tip">鼠標(biāo)懸停顯示氣泡</span> <div class="content"> <span>The quick fox jumps over a lazy dog.</span> </div> </div> <script type="text/javascript"> $(function(){ $("#xsztip").hover(function(){ show_xszimg(this); },function(){ hide_xszimg(this); }); $("#xsztip2").hover(function(){ show_xszimg(this); },function(){ hide_xszimg(this); }); $("#xsztip3").hover(function(){ show_xszimg(this); },function(){ hide_xszimg(this); }); function hide_xszimg(f){ $(f).next().hide() } function show_xszimg(f){ var c=$(f); var e=c.offset(); var a=e.left; var b=e.top+40; $(f).next().css({left:a+"px",top:b+"px"}).show(); } }); </script> </body> </html>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
淺談jQuery中的eq()與DOM中element.[]的區(qū)別
下面小編就為大家?guī)硪黄獪\談jQuery中的eq()與DOM中element.[]的區(qū)別。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-10-10jQuery EasyUI Layout實(shí)現(xiàn)tabs標(biāo)簽的實(shí)例
這篇文章主要介紹了jQuery EasyUI Layout實(shí)現(xiàn)tabs標(biāo)簽的實(shí)例的相關(guān)資料,希望通過本文能幫助到大家實(shí)現(xiàn)這樣的功能,需要的朋友可以參考下2017-09-09jquery實(shí)現(xiàn)tab鍵進(jìn)行選擇后enter鍵觸發(fā)click行為
本文主要介紹了jquery鍵盤事件實(shí)現(xiàn)tab鍵進(jìn)行選擇后enter鍵觸發(fā)click行為的方法,這種使用場景為當(dāng)首頁有幾個鏈接需要選擇的時候,使用鍵盤就可以進(jìn)行觸發(fā)行為。下面跟著小編一起來看下吧2017-03-03easyui datebox 時間限制,datebox開始時間限制結(jié)束時間,datebox截止日期比起始日期大的實(shí)現(xiàn)代碼
這篇文章主要介紹了easyui datebox 時間限制,datebox開始時間限制結(jié)束時間,datebox截止日期比起始日期大的實(shí)現(xiàn)代碼,需要的朋友參考下吧2017-01-01JQuery 學(xué)習(xí)筆記 element屬性控制
JQuery元素屬性控制2009-07-07