バックグラウンドに0.3不透明度の画像があり、背景色もあるシンプルなサイトを作った。その上に何かテキストがあります。ここにHTMLがあります:相対的位置付けが不透明を除去するのはなぜですか?
私が相対的な位置にすると、テキストは画像の不透明度には影響されません。それを相対的にしないと、不透明度の影響を受けます。私はなぜ相対的な位置付けがそのような効果を持っているのだろうと思っています。あなたが見ている何
.bg-1 {
width: 100%;
height: 80vh;
background: url(img/keyboard.jpg) no-repeat center center;
background-position: top;
background-size: cover;
opacity: .3;
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
}
#welcome {
padding-top: 15px;
color: #66FCF1;
z-index: 1;
position: relative;
/*this is the point of concern*/
}
.first {
width: 100%;
height: 80vh;
background-color: black;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container-fluid first text-center">
<div id="welcome">
<p class="welcomeSize">Welcome!</p>
</div>
<div class="bg-1">
<!--the bg image with opacity-->
</div>
</div>