使用 CSS3 设置图像亮度

cssweb developmentfront end technology更新于 2024/11/17 16:44:17

要在 CSS 中设置图像亮度,请使用滤镜"亮度(%)"。请记住,值为 0 时图像会变黑,值为 100% 时为原始图像的默认亮度。其余值您可以自行设置,但高于 100% 的值会使图像更亮。

示例

现在让我们看一个例子 −

<!DOCTYPE html>
<html>
<head>
<style>
img.demo {
   filter: brightness(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 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>

输出


相关文章


有用资源