問題可以通過在CSS中:hover
僞類和jQuery的的onmouseover
和onmouseout
事件之間的衝突引起的。我想我已經找到了解決的背景下失去了過濾器,當你將鼠標懸停在綠色的勾,但:
JSFiddle
出現在IE9和Chrome的工作依然。 JSFiddle在Firefox中不起作用,但我認爲這是由於其他原因。
我基本上改組了jQuery onmouseover
和onmouseout
事件到事件hover()
(I懷疑這取得的差),並評論指出,在.grayscale
類設置opacity
屬性的行。
看看IE9,讓我知道你的想法。
$(document).ready(function() {
$(".inspire-me").hover(function() {
$(this).addClass("on");
// $(this).find('.grayscale').css('opacity', '0.50');
$(this).find('.content-lower').css('opacity', '1');
var margin = $(this).find('.grayscale').height()/2;
var half = margin - 17;
$(this).find('.hide').css('visibility', 'visible');
$('.hide').css({'top' : half});
}
,
function() {
$(this).removeClass("on");
// $(this).find('.grayscale').css('opacity', '1');
$(this).find('.hide').css('visibility', 'hidden');
});
UPDATE
我已經在CSS中指定的filter
財產全SVG XML得到了在Firefox這個工作現在:
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");
Updated Fiddle
我看到你嘗試在代碼中使用mouseenter/mouseleave事件,但它是評論了 - 爲什麼,這是不是按預期工作?這些事件實際上是更喜歡的事件 - 因爲當您將鼠標懸停在子元素上時,mouseover/mouseout已經觸發,這不是您想要的。 – CBroe 2013-04-05 10:46:42
我試圖使用mouseenter/mouseleave,但它似乎沒有爲我工作,我也嘗試懸停狀態,鼠標進出,可悲似乎沒有任何工作。 – user1844398 2013-04-05 11:08:16