欢迎CSDN博客专栏CSDN专栏 Java全栈之路,Github主页

#简单的说就是使用rgba的写法,如例所示:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>文字透明,背景不透明</title>
<style>
.div1{width:293px;height:219px;background:url(1.jpg) no-repeat;}
.div2{width:293px;height:100px;background:rgba(255,0,0,0.5);text-align: center;
font-family:"Microsoft Yahei";font-size: 30px;color:#fff;}
</style>
</head>
<body>
<div class="div1">
<div class="div2">中华人民共和国万岁</div>
</div>
</body>
</html>

css