gpt4 book ai didi

CSS RGBA 灰度图像到彩色图像的颜色代码

转载 作者:行者123 更新时间:2023-11-28 10:30:37 31 4
gpt4 key购买 nike

我想通过 CCS3 创建简单的悬停效果,例如默认图像是黑白的,但是当我悬停到该图像时,将显示该图像的实际颜色。

请帮帮我

最佳答案

您可以使用新属性 filter 但浏览器支持不是很深(参见 http://caniuse.com/css-filters )

JSfiddle Demo

CSS

img {
-webkit-filter:grayscale(100%);
}

img:hover {
-webkit-filter:none;
}

替代方法

这需要一个包装 div 和第二个彩色背景图像

JSfiddle

HTML

<div class="wrap">
<img src="http://lorempixel.com/output/abstract-q-g-250-250-8.jpg" alt=""/>
</div>

CSS

.wrap {
display: inline-block;
background-image: url(http://lorempixel.com/output/abstract-q-c-250-250-8.jpg);
}

img {
display: block;
}

.wrap img:hover {
opacity:0;
}

关于CSS RGBA 灰度图像到彩色图像的颜色代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23540172/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com