2

我想知道是否有任何好的解决方案可用于将彩色图像转换为黑白固态并允许它在鼠标悬停时使用 jQuery 转换回彩色图像?

我尝试了这里描述的 CSS 方法:Image Greyscale with CSS & re-color on mouse-over? ,但我运气不好。

这是当前站点: http: //frixel.com/wp/ - 我正在尝试在画廊网格上创建效果。

4

3 回答 3

6

嘿,您在谈论 CSS 过滤器...这是您需要将此代码添加到主样式表文件的内容;)

.portfolio:hover {
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
filter: grayscale(100%);
filter: gray;
-webkit-filter: grayscale(1);
}
于 2013-08-27T16:14:38.057 回答
3

也许一个解决方案是使用这个插件:

http://gianlucaguarini.com/canvas-experiments/jQuery.BlackAndWhite/

带有轮播的演示:http: //interio.tohidgolkar.com/shortcodes/clients-carousel/

于 2013-12-03T11:24:04.393 回答
0

使用下面的代码,它有助于在黑白图像上创建彩色图像鼠标悬停。:

<style>
.blk-white{-webkit-filter: grayscale(100%); filter: grayscale(100%);}
</style>
<script src="http://code.jquery.com/jquery-2.1.1.js"></script>
<script type="text/javascript">
function display_blackwhite(obj) {
$(obj).addClass("blk-white");
}
function display_colorphoto(obj) {
$(obj).removeClass("blk-white");
}
</script>
</head>
<body>
<img src="change-colorphoto-black-white1.jpg" onMouseOver="display_blackwhite(this)" onMouseOut="display_colorphoto(this)" width="350"/>
<img src="change-colorphoto-black-white2.png" onMouseOver="display_blackwhite(this)" onMouseOut="display_colorphoto(this)" width="350"/>
于 2016-12-28T10:12:39.830 回答