【发布时间】:2021-03-16 21:03:22
【问题描述】:
我的背景有问题。我想要和截图 1 一样,但我和截图 2 一样。
问题出在哪里?
html,
body,
.bg-for-1 {
height: 100%;
}
.bg-for-1 {
background: black;
}
.bg-for-1 .first {
position: absolute;
opacity: 0.2;
width: 100%;
height: 100%;
background-image: url(http://digitalresult.com/wp-content/uploads/2016/06/beautiful-reflection-at-lake-pier-wallpaper-32.jpeg);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.bg-for-1 .first h3 {
color: white;
position: relative;
text-align: center;
}
<div class="bg-for-1"><div class="first"><h3>Hello</h3></div></div>
【问题讨论】:
-
缺少您的 html 以清楚地证明您的问题 ;) 您可以更新您的 sn-p ;) 但是,看起来像:
.first h3使 h3 成为 .first 的子级,其中设置了不透明度,所以它也是半透明的.. -
你好
标签: css background-image opacity