I am trying to make an image be seen under a colored div. But when I make the div 50% opacity, the lettering inside also goes to 50%. Making the p 100% opacity does not make it 100% opaque. How do I make the div background 50% opaque and the text in the div 100% opaque?
CSS:
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
line-height: 1.6em;
font-size: 18px;
}
.topPanel {
width:100vw;
height:50vh;
background-color: gray;
overflow: scroll;
filter: alpha(opacity=50);
opacity: 0.5;
}
.bottomPanel {
width:100vw;
height:50vh;
background-color: yellow;
clear:both;
overflow: scroll;
filter: alpha(opacity=50);
opacity: 0.5;
}
.grouped {
position: absolute;
top:0;
left:0;
z-index: 100; /* only works with positioned elements */
display: block;
}
p {
padding: 0 2rem;
filter: alpha(opacity=100);
opacity: 1;
}
h3 {
padding: 1rem 0;
text-align: center;
}
.background {
width: 100vw;
height: 100vh;
overflow: hidden;
}
.background img {
width: 100vw;
z-index: -1;
filter: alpha(opacity=50);
opacity: 0.5;
}
HTML:
<body>
<div class="background">
<img class="bgPic" src="img/b64d-chassis.jpg">
</div>
<div class="grouped">
<div class="topPanel">
<h3>title</h3><p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
<h3>title</h3
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
</div><!-- topPanel -->
<div class="bottomPanel">
</div><!-- bottomPanel -->
</div><!-- grouped -->
</body>