html – 悬停时的黑白CSS背景

前端之家收集整理的这篇文章主要介绍了html – 悬停时的黑白CSS背景前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个CSS精灵像:

HTML

<a id="estates" href="http://www.domain.com/estate"></a>

CSS

#estates {background-position: -200px 0px;width: 96px;height: 90px;}

#estates {background: url("http://www.domain.com/images/sprite.png") no-repeat scroll 0% 0% transparent;float: left;margin: 22px -2px 30px 33px;}

我希望当用户将鼠标悬停在链接上时将图像颜色更改为黑白或者如果不能发生则覆盖透明png?

解决方法

您可以查看CSS灰度过滤器.它符合以下方面:
#estates:hover {
  -webkit-filter: grayscale(100%);
  -moz-filter: grayscale(100%);
  -ms-filter: grayscale(100%);
  -o-filter: grayscale(100%);
  filter: grayscale(100%);
  filter: url(grayscale.svg); /* Firefox 4+ */
  filter: gray; /* IE 6-9 */;
}

只是不要忘记添加浏览器支持所需的其他一百件内容

我找到了其他一百件东西并添加了它们.

原文链接:https://www.f2er.com/html/225499.html

猜你在找的HTML相关文章