灰度图片 css_使用CSS滤镜将图像显示为灰度

本文介绍了如何使用CSS滤镜将图像显示为灰度,只需应用简单的CSS代码即可实现。此外,还提到了CSS过滤器的更多可能性,如动画效果,并指出尽管CSS滤镜会影响在线显示,但原始图像在下载时仍保持彩色。
摘要由CSDN通过智能技术生成

灰度图片 css

CSS filters aren't yet widely supported but they are indeed impressive and a modern need for web imagery.  CSS filters allow you to modify the display of images in a variety of ways, one of those ways being displaying images as grayscale.

CSS过滤器尚未得到广泛支持,但它们确实令人印象深刻,并且是对Web图像的现代需求。 CSS过滤器允许您以多种方式修改图像的显示,其中一种方式是将图像显示为灰度。

Doing so requires the most minimal of CSS:

这样做需要最少CSS:


img.bw {
	filter: grayscale(1);
}


You can even animate an image to or from grayscale:

您甚至可以为图像设置灰度或从灰度设置动画:


img.bw {
	filter: grayscale(0);
}

img.bw.grey {
	filter: grayscale(1);
	transition-property: filter;
	transition-duration: 1s;	
}


CSS filters allow much more than just grayscale adjustments, so if you haven't taken the time, please play around with my CSS filter sandbox.  Remember that if the user chooses to download the image, it is downloaded in its original colored displays, but for online display purposes, CSS filters do the trick!

CSS过滤器不仅仅可以进行灰度调整,因此,如果您还没有花时间,请试用我的CSS过滤器沙箱 。 请记住,如果用户选择下载图像,则会以其原始的彩色显示器下载该图像,但是出于在线显示目的,CSS过滤器可以解决问题!

翻译自: https://davidwalsh.name/convert-images-grayscale

灰度图片 css

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值