使用 CSS 为背景添加透明度
cssweb developmentfront end technology更新于 2025/6/5 8:12:17
使用 opacity 属性为元素的背景添加透明度。您可以尝试运行以下代码。
示例
<!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: #808000;
padding: 20px;
}
div.one {
opacity: 0.2;
filter: alpha(opacity=20);
}
div.two {
opacity: 0.5;
filter: alpha(opacity=50);
}
</style>
</head>
<body>
<h1>Heading</h1>
<p>Check transparency in the below section:</p>
<div class = "one">
<p>opacity 0.2</p>
</div>
<div class = "two">
<p>opacity 0.5</p>
</div>
<div>
<p>opacity 1</p>
</div>
</body>
</html>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

