我想做一個簡單的動畫與jQuery在火狐瀏覽器中工作絕對好,但它在Chrome和邊緣閃爍,這裏是一個jsfiddle,這裏是代碼:隱藏和顯示元素與jQuery在Chrome和邊緣閃爍
HTML
<div id="boxes-wrapper">
<div class="box"></div><div class="box"></div><div class="box"></div>
</div>
CSS
.box {
width: 150px;
height: 150px;
display: inline-block;
margin: 0;
padding: 0;
vertical-align: top;
}
.box:first-child {
background: pink;
}
.box:nth-child(2) {
background: skyblue;
}
.box:nth-child(3) {
background: gold;
}
.box.hover {
position: relative;
z-index: 20;
}
html, body {
position: relative;
width: 100%;
height: 100%;
}
#shadow {
display: none;
position: absolute;
left: 0;
top: 0;
background: black;
opacity: 0.7;
z-index: 10;
width: 100%;
height: 100%;
}
的JavaScript
$('.box').hover(function() {
$(this).addClass('hover');
$('#shadow').show();
}, function() {
$(this).removeClass('hover');
$('#shadow').hide();
});
我已經挖了上這麼幾個問題,但沒有一個人回答如何擺脫閃爍的。
爲什麼不去做一個單獨懸停你的影子,所以它顯示在盒子包裝懸停 – Pete
因爲我需要知道哪個孩子觸發懸停,所以我可以添加一個類到它 –
實際上看過你的代碼,它是不可能做你想要的,如果你確實隱藏了覆蓋層(這是導致閃爍的原因),所以沒有辦法ö懸停在另一個框和非懸停框在覆蓋 – Pete