使用 CSS3 调整图像对比度
cssweb developmentfront end technology更新于 2024/11/4 7:08:17
要在 CSS 中设置图像对比度,请使用滤镜"对比度(%)"。请记住,值为 0 时图像将变为黑色,值为 100% 时为原始图像的默认值。其余值您可以自行选择,但高于 100% 的值会使图像对比度更高。
示例
现在让我们看一个使用 CSS3 调整图像对比度的示例 −
<!DOCTYPE html>
<html>
<head>
<style>
img.demo {
filter: brightness(120%);
filter: contrast(120%);
}
</style>
</head>
<body>
<h1>Learn MySQL</h1>
<img src="https://www.cainiaomax.com/mysql/images/mysql-mini-logo.jpg" alt="MySQL" width="160" height="150">
<h1>Learn MySQL</h1>
<p>Below image is brighter and has more contrast than the original image above.</p>
<img class="demo" src="https://www.cainiaomax.com/mysql/images/mysql-mini-logo.jpg" alt="MySQL" width="160" height="150">
</body>
</html>
输出

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

