您好,登錄后才能下訂單哦!
這期內(nèi)容當中小編將會給大家?guī)碛嘘P(guān)利用jquery怎么實現(xiàn)一個鼠標懸浮彈提示框功能,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
//別忘了導入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">鼠標懸停顯示氣泡</span> <div class="content"> <span>The quick fox jumps over a lazy dog.</span> </div> <span id="xsztip2" class="tip">鼠標懸停顯示氣泡</span> <div class="content"> <span>The quick fox jumps over a lazy dog.</span> </div> <span id="xsztip3" class="tip">鼠標懸停顯示氣泡</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>
上述就是小編為大家分享的利用jquery怎么實現(xiàn)一個鼠標懸浮彈提示框功能了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道。
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。