关于CSS中不透明属性的问题。 我有一个标题头,我有一个不透明的.3应用于它(以及一个过渡,但这不是问题的关键)。 这里是一个GIF:CSS中的不透明度适用于子div
现在,我喜欢的标题有,你可以很明显的看出其背后的图像效果,但我想标题本身出现白色,不透明度为1。由于的不透明度应用于其父div(标题),它看起来像div的其余部分一样褪色。 有没有办法做到这一点?换句话说,有没有办法“覆盖”父元素的不透明度?
html,
body {
margin: 0px;
padding: 0px;
height: 100vh;
}
#header {
position: absolute;
width: 100vw;
height: 0vh;
background-color: black;
opacity: 0;
z-index: 6;
transition: height 1s ease, opacity 1s ease;
}
#hoverable {
position: absolute;
height: 10vh;
width: 100%;
z-index: 7;
}
#hoverable:hover #header {
opacity: .3;
height: 10vh;
}
#title {
margin-left: 10vw;
line-height: 10vh;
float: left;
}
<div id="hoverable">
<div id="header">
<div id="title">
<h1>TITLE</h1>
</div>
</div>
</div>
的[我不想继承的CSS父孩子不透明度]可能的复制(http://stackoverflow.com/questions/5770341/i-do-not-want-to-继承-的孩子,不透明度,来自该家长在-CSS) –