【发布时间】:2023-04-04 06:42:01
【问题描述】:
我有四个div,box1、box2、box3和box4,并使用旋转让它们按顺序重叠。我使用 jquery hover 函数在鼠标悬停在目标 dev 上时显示某些提示,但我发现该事件很混乱,并且受到干扰。如何处理事件并防止一个 div 事件影响另一个。
这是我的代码:
html:
<div class="wrap">
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="box4"></div>
</div>
css:
.wrap {
width: 400px;
height: 400px;
position:relative;
-webkit-perspective: 700px;
-moz-perspective: 700px;
-ms-perspective: 700px;
perspective: 700px;
}
.wrap div {
position:absolute;
left:50%;top:50%;
-webkit-transform: rotateX(69deg) rotateY(0deg) rotateZ(0deg) scaleX(.73) scaleY(.73) scaleZ(1);
-moz-transform: rotateX(69deg) rotateY(0deg) rotateZ(0deg) scaleX(.73) scaleY(.73) scaleZ(1);
-ms-transform: rotateX(69deg) rotateY(0deg) rotateZ(0deg) scaleX(.73) scaleY(.73) scaleZ(1);
transform: rotateX(69deg) rotateY(0deg) rotateZ(0deg) scaleX(.73) scaleY(.73) scaleZ(1);
}
.box1 {
width:400px;
height:400px;
margin-left: -200px;margin-top:-200px;
}
.box2 {
width:300px;
height:300px;
margin-left: -150px;margin-top:-150px;
}
.box3 {
width:200px;
height:200px;
margin-left: -100px;margin-top:-100px;
}
.box4 {
width:100px;
height:100px;
margin-left: -50px;margin-top:-50px;
}
js:
$(".wrap div").hover(function(event){
console.log(event.currentTarget);
},function(event) {
console.log(event.currentTarget);
});
【问题讨论】:
-
为什么没有基于类的悬停效果??
-
好主意,我试试看。
-
我为你尝试了同样的方法.. 发布答案.. 让我知道它是否有效..
-
@viraj 谢谢,但它不起作用,作为答案评论
-
我已经编辑了答案..
标签: javascript