Reputation: 815
I'm wondering if there are any good solutions available for turning a color image into a black/white solid state and allowing it to transition back into a colored image on mouse over using jQuery?
I tried a CSS method as described here: Image Greyscale with CSS & re-color on mouse-over?, but I'm not having much luck with it.
Here is the current site: http://frixel.com/wp/ - I am trying to create the effect on the gallery grid.
Upvotes: 2
Views: 13565
Reputation: 911
Use this below code, It helps to create colored image mouseover on black/white image.:
<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"/>
Upvotes: 0
Reputation: 959
maybe a solution would be to use this plugin:
http://gianlucaguarini.com/canvas-experiments/jQuery.BlackAndWhite/
a demo with carousel: http://interio.tohidgolkar.com/shortcodes/clients-carousel/
Upvotes: 3
Reputation: 112
Hey you are talking about CSS filters... this what you need add this code to your main stylesheet file ;)
.portfolio:hover {
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
filter: grayscale(100%);
filter: gray;
-webkit-filter: grayscale(1);
}
Upvotes: 6