使用 CSS3 将图像转换为灰度图像
cssweb developmentfront end technology更新于 2024/11/19 19:24:17
要在 CSS3 中将图像转换为灰度图像,请使用滤镜属性的灰度值。
示例
让我们看一个例子 −
<!DOCTYPE html>
<html>
<head>
<style>
img.demo {
filter: brightness(120%);
filter: contrast(120%);
filter: grayscale(130%);
}
</style>
</head>
<body>
<h1>Spring Framework</h1>
<img src="https://www.cainiaomax.com/spring/images/spring-mini-logo.jpg" alt="Spring" width="160" height="150">
<h1>Learn MySQL</h1>
<p>Below image is brighter and has more contrast than the original image above. With that the image is in grayscale:</p>
<img class="demo" src="https://www.cainiaomax.com/spring/images/spring-mini-logo.jpg" alt="Spring" width="160" height="150">
</body>
</html>
输出

相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

