我有四個div,box1,box2,box3和box4,並使用rotate使它們按順序重疊。我使用jquery hover
函數來顯示某些提示,當鼠標在目標dev上時,但我發現該事件是混亂的,並且受到干擾。如何處理事件並防止一個div事件影響另一個事件。 這裏是我的代碼:如何組織多個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);
});
爲什麼沒有基於類的懸停效果? –
好主意,我會嘗試。 – callblueday
我也一樣爲你..發佈在答案..讓我知道,如果它的工作.. –