可能重复:
CSS Opacity 属性
我正在一个具有透明度的图像上制作一个图层,我在那里遇到了问题。
当我在图层上写下任何文本时,它们也会获得相同的透明度。
我认为这是因为继承问题并添加了“位置:相对”来重置我的子 div,但它根本不起作用。
我只想重置子div的不透明度(下面的#TXT)。
这是我的代码。
<!DOCTYPE html>
<html>
<header>
<meta charset="UTF-8">
<style type="text/css">
*{margin: 0; padding:0; background-color: #555;}
#wrapper {
margin:0 auto;
background-color: white;
width: 922px;
height:349px;
margin-top: 150px;
-webkit-box-shadow: 0px 0px 7px 7px #333;
-moz-box-shadow: 0px 0px 7px 7px #333;
}
#ImgSection {
width: 922px;
height: 349px;
background-color: white;
position: absolute;
background: url("brand-new-car.jpg") -50px -200px no-repeat;
}
#TxtSection {
width: 322px;
height: 349px;
background-color: #222;
opacity: .5;
float: right;
-webkit-box-shadow: inset 3px 0px 3px 0px black;
-moz-box-shadow: inset 3px 0px 3px 0px black;
}
#TXT{
position: relative;
font-size: 50px;
opacity: 1;
}
</style>
<script type="text/javascript">
</script>
</header>
<body>
<div id="wrapper">
<div id="ImgSection"></div>
<div id="TxtSection">
<div id="TXT">dsdsad</div>
</div>
</div>
</body>
</html>
图像brand-new-car.jpg 的大小为1024x768。
我想知道如何重置#TXT 的不透明度。
请帮忙。
提前致谢。