我正在尝试实现这种“圈子/图层”效果(https://www.thinglink.com/)
我的jQuery技能非常糟糕:(这就是我所做的,到目前为止......
HTML
<body style="margin:0; padding:0;">
<div class="container">
<div class="bubble-container bubble-a">
<a class="gps_ring" href="javascript:void(0);">
<div class="dot">dot</div>
</a>
<div class="layer">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
<div class="bubble-container bubble-b">
<a class="gps_ring" href="javascript:void(0);">
<div class="dot">dot</div>
</a>
<div class="layer">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
<div class="bubble-container bubble-c">
<a class="gps_ring" href="javascript:void(0);">
<div class="dot">dot</div>
</a>
<div class="layer">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
</div>
</body>
CSS
.container { background-color:black; width:100%; height:400px; }
.layer { background-color:#FFFFFF; display:none; position:absolute; top:-70px; right:20px; width:200px; height:200px; z-index:99999999; overflow:hidden; }
.gps_ring {
border: 2px solid #ffffff;
padding:6px;
-webkit-border-radius: 30px;
height: 30px;
width: 30px;
display:block;
-webkit-animation: 0.6s pulsate infinite alternate ease-in-out;
-moz-animation: 0.6s pulsate infinite alternate ease-in-out;
-ms-animation: 0.6s pulsate infinite alternate ease-in-out;
-o-animation: 0.6s pulsate infinite alternate ease-in-out;
animation: 0.6s pulsate infinite alternate ease-in-out;
opacity: 0.0;
}
.gps_ring div.dot { background-color:transparent; width:100%; height:100%; -webkit-border-radius:30px; outline:none; text-indent:-9999px; }
.gps_ring:hover div.dot { background-color:#ef4036; }
.bubble-container { position: absolute; }
.bubble-a {
left:150px;
top:100px;
}
.bubble-b {
left:250px;
top:260px;
}
.bubble-c {
left:350px;
top:180px;
}
@-webkit-keyframes pulsate {
0% {-webkit-transform: scale(1.0, 1.0); opacity: 1.0;}
50% {opacity: 1.0;}
100% {-webkit-transform: scale(1.3, 1.3); opacity: 1.0;}
}
的jQuery
$(".bubble-container .gps_ring").hover(function(){
$(this).next().show();
$(this).next().focus();
});
$(".layer").mouseleave(function(){
$(this).hide();
});
有时鼠标外出时白色层不会隐藏,你知道为什么吗?
另外,当我在白色图层上时,我想设置红点。
谢谢!
答案 0 :(得分:3)
$(".bubble-container").hover(function(){
$(this).find('.gps_ring').next('.layer').show();
},function(){
$(this).find('.gps_ring').next('.layer').hide();
});
或者你可以使用.find()
$(".bubble-container").hover(function(){
$(this).find('.layer').show();
},function(){
$(this).find('.layer').hide();
});