【发布时间】:2016-11-02 00:18:20
【问题描述】:
我在使用过滤器和 jQuery 时遇到问题。
$(document).ready(function(){
$("img").mouseenter(function(){
$("overlay").show("slide", { direction: "up" }, 600);
$('img').addClass("gray");
});
$("overlay").mouseleave(function (){
$("img").hide("slide", { direction: "up" }, 600);
});
});
.gray {
filter: grayscale(1);
-moz-filter: grayscale(1);
-webkit-filter: grayscale(1)
}
#g1 {
display: none;
position: absolute;
background: rgba(0, 0, 0, .8);
width: 100%;
height: 100%;
}
<div id="g1">
Some text to go on overlay<br/>
<a href="#">READ MORE</a>
</div>
<img alt="" src="/portals/197/gfm/gb1.jpg" width="100%">
因此,在悬停时,我希望叠加层与文本/按钮一起显示,并且叠加层后面的图像是灰度的。但是灰度似乎阻止了叠加层的显示。
关于如何完成这项工作的任何想法?
【问题讨论】:
标签: jquery css filter overlay grayscale