我有一個jQuery鼠標懸停功能在我的網站(click here and scroll down to images with coloured blocks)。我已經注意到懸停狀態圖像是不可見的,雖然我玩過Z指數。什麼導致這個問題?鼠標懸停不能使用jQuery
下面是我的代碼片段。
<div class="shirt-block" style="background:#333334;">
<figure>
<img class="shirt col-img-inner" src="img/B0713011sf2.jpg" alt="alt"/>
</figure>
</div>
.shirt-block {
width:47%;
float:left;
margin:0; padding:0;
margin-left:2%;
min-width:200px;
max-width:600px;
position:relative;
}
.shirt-block > figure { margin:0; padding:0; height:100%; position:absolute; top:0; right:0; width:100%; }
.shirt-sizer { width:100%; /* same as figure width */ }
.shirt {
width:100%;
position:absolute;
top:0;
right:0;
}
.shirt-hover {
background:url(http://www.lybstore.com/img/home-hover-bg.png);
background-size:cover;
position:absolute;
top:0; right:0;
z-index:100;
width:100%;
height:100%;
opacity:0;
}
$('figure').append('<div class="shirt-hover"/>');
var $sizer = $("<img/>", {src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAF8AAABkCAMAAADXLxypAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAACBJREFUeNrtwTEBAAAAwiD7p14Hb2AAAAAAAAAAAABcAiWAAAEKyWyqAAAAAElFTkSuQmCC"}).addClass("shirt-sizer");
$('.shirt-block').append($sizer);
$('.shirt-hover').hover(function(){
$(this).stop().animate({opacity:1},200);
},function(){
$(this).stop().animate({opacity:0},200);
});
您的網站有一些JS似乎是jQuery的懸停事件,但它被註釋掉。您能否驗證並將腳本添加到帖子中? – Fallexe
@Flex不知道是不是你降級了我,但它被評論的原因是bcos我正在測試下面給出的答案 – NewBoy