如何使用CSS去饱和div的背景图像?

MKA*_*Aka 6 html javascript html5 css3

我看到这么多的插件去了一个图像去饱和 标签.

但我没有找到任何去饱和背景图像的东西,(一个用作元素背景的图像(div).

有没有办法在悬停时使用2个背景去饱和背景图像(即图像精灵一个是B&W,另一个是颜色)

我可以使用Image Sprites做这样的事情.

// Initially color Image    
$(<element>).mouseover(function(e){

                    jQuery(this).children(":first").stop().animate(
                    {
                        'background-position': <some coordinates>
                        // Coordinates of b&w Image  
                    },
                    100                       
                    );

                    e.stopPropagation();
                })
                .mouseout(function(e){

                    jQuery(this).children(":first").stop().animate(
                    {
                        'background-position': <some coordinates>
                          // Coordinates of color Image   
                    },
                    100,
                    settings.easingType
                    );

                    e.stopPropagation();
                });
Run Code Online (Sandbox Code Playgroud)

但我不想要这个.我想要飞行中的饱和背景图像.请帮忙.

MKA*_*Aka 1

element: hover{
     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");
    -webkit-filter: grayscale(100%);
    -moz-filter:    grayscale(100%);
    -ms-filter:     grayscale(100%);
    -o-filter:      grayscale(100%);
    filter: gray;
}
Run Code Online (Sandbox Code Playgroud)

这是相关的问题,希望有人需要重定向。

CSS 仅在 Div 中的其他图像保持饱和的情况下降低背景图像的饱和度