- css实现背景和文字均为黑色,背景透明度为0.2,文字不透明:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
div {
background: rgba(0, 0, 0, 0.2) none repeat scroll !important;
background: #ffffff;
filter: Alpha(opacity=20);
width: 200px;
height: 300px;
color: #000000;
font-size: 20px;
font-weight: bold;
}
div p {
position: relative;
}
</style>
</head>
<body>
<div>
<p style="position: relative;">这是个background透明但是content不透明的div</p>
</div>
</body>
</html>