jquery实现⿏标悬浮弹出⽓泡提⽰框
jquery⿏标悬浮弹出⽓泡提⽰框,供⼤家参考,具体内容如下
居中的图⽚
代码
我在⽹上了很多例⼦都是单独的⼀个,所以我修改了jquery的⼀点代码,让它可以在⼀个页⾯上多次使⽤,原⽂的地址我没到,相信我这个会更好⼀点。
//别忘了导⼊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;
}
jquery实现ajax.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 p+40;
$(f).next().css({left:a+"px",top:b+"px"}).show();
}
});
</script>
</body>
</html>
以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。