如何使用 CSS 为图片添加视觉效果?
cssweb developmentfront end technology更新于 2025/9/28 6:36:17
以下是使用 CSS 为图片添加视觉效果的代码 −
示例
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
img{
margin: 20px;
}
img.normal{
margin-left: 30%;
width: 300px;
height: 300px;
}
img.filter {
width: 300px;
height: 300px;
filter: invert(100%);
}
</style>
</head>
<body>
<h1 style="text-align: center;">CSS Image effects example</h1>
<img class="normal" src="https://i.picsum.photos/id/237/536/354.jpg">
<img class="filter" src="https://i.picsum.photos/id/237/536/354.jpg">
</body>
</html>
输出
上述代码将产生以下输出 −

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

