<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="author" content="微普科技 http://www.wiipu.com" />
<title>网页常见背景透明,文字不透明</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
.zmkt div{
width:500px;
height:300px;
background:#f00;
opacity: 0.2;
}
.sub{
height:50px;
text-aligh:center;
background:#000;
color:#fff;
text-align: center;
line-height: 300px;//垂直居中
}
</style>
</head>
<body>
<div class="zmkt">
外层div背景透明,背景颜色为#f00,透明度为20%,
<div class="sub">内层文字不透明,背景颜色为#000,字体颜色为#fff</div>
</div>
</body>
</html>
转载于:https://my.oschina.net/kitty0107/blog/1626078