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實(shí)現(xiàn)二級導(dǎo)航下拉菜單效果
這篇文章主要介紹了jquery實(shí)現(xiàn)二級導(dǎo)航下拉菜單效果,具有一定參考借鑒價值,需要的朋友可以參考下2015-12-12
jquery中交替點(diǎn)擊事件的實(shí)現(xiàn)代碼
這篇文章主要介紹了jquery中交替點(diǎn)擊事件的實(shí)現(xiàn)代碼,需要的朋友可以參考下2014-02-02
jquery動態(tài)賦值id與動態(tài)取id方法示例
這篇文章主要給大家介紹了關(guān)于jquery動態(tài)賦值id與動態(tài)取id的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面跟著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2017-08-08
jquery代碼實(shí)現(xiàn)多選、不同分享功能
這篇文章主要介紹了jquery代碼實(shí)現(xiàn)多選、不同分享功能,需要的朋友可以參考下2015-07-07
jQuery基于muipicker實(shí)現(xiàn)仿ios時間選擇
本文給大家分享的是把jQuery的muipicker插件修改實(shí)現(xiàn)仿IOS時間選擇特效,非常的不錯,有需要的小伙伴可以參考下。2016-02-02
jquery UI Datepicker時間控件的使用方法(加強(qiáng)版)
這篇文章繼續(xù)介紹了jquery UI Datepicker時間控件的使用方法,主要關(guān)于Datepicker插件的介紹和使用,并分享了第一個日歷插件的使用實(shí)例,需要的朋友可以參考下2015-11-11

