【发布时间】:2020-07-31 01:30:42
【问题描述】:
我已将 background-image 应用于 class="hero-contact-us" 和 opacity=0.3 的 div。我无法弄清楚为什么 opacity 属性应用于 class="hero-contact-us-text" 的子元素。非常感谢您的帮助。
<div class="hero-contact-us">
<div class="hero-contact-us-text">Some text here</div>
</div>
这里是 CSS
.hero-contact-us
{
background-image: url('media/pexels-ruslan-burlaka-140945.jpg');
background-position: center;
background-size: cover;
background-repeat: no-repeat;
opacity: 0.3;
position: relative;
}
.hero-contact-us-text
{
position: absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
color:#173348;
font-size: 1.5em;
z-index: 99;
opacity: 1;
}
【问题讨论】:
-
因为
hero-contact-us是父母。
标签: javascript html css frontend