CodeLab
Show Output
 
xxxxxxxxxx
21
 
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<meta charset="utf-8">
5
<title>CSS Opacity Using RGBA Colors</title>
6
<style>
7
    body {
8
        background-image: url("/examples/images/pattern.jpg");
9
    }
10
    p{
11
        padding: 20px;
12
        background: rgba(0, 0, 0, 0.6);
13
        color: #fff;
14
        font: 18px Arial, sans-serif;
15
    }
16
</style>
17
</head>
18
<body>
19
    <p>Setting background transparency without affecting the text content.</p>
20
</body>
21
</html>
 

在微博、微信、公众号、小程序分享此示例。 如果您觉得有帮助,请给我们一个赞。