使用 RGBA 实现 CSS 透明度
cssweb developmentfront end technology更新于 2025/11/27 3:24:17
使用 RGBA() 值实现 CSS 透明度。设置 Alpha 通道参数可指定颜色的不透明度。
以下是使用 RGBA 实现 CSS 透明度的代码−
示例
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
div {
width: 200px;
height: 200px;
background-color: rgb(0, 0, 255);
color: white;
display: inline-block;
}
.transparent {
background-color: rgba(0, 0, 255, 0.582);
}
</style>
</head>
<body>
<h1>Transparency using RGBA example</h1>
<div class="transparent">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Hic, accusantium.
</div>
<div>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, nisi!
</div>
</body>
</html>
输出
上述代码将产生以下输出 −

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

