Parent's transparent background is making child images transparent

Johnny

I have set my main background to transparent, I am placing an image on top of the background it is inheriting the opacity 0.4, I don't want that. I want it to be 100%. I even tried opacity 1.0 didn't work here is my code:

HTML:

<!-- Background -->
<img src="img/bg.jpg" id="bg" alt="">

<!-- The image -->
<div class = "row">
    <div class = "logo">

      <img src="img/logo.png" width="100%" height="141" id="logo" alt="Title" /> 
      </div>
      </div>

CSS:

//Background
    #bg {
      position: fixed; 
      top: 0; 
      left: 0;
      opacity: 0.4; 

      width: 100%;
      min-height: 100%;
    }

//the image
#logo {
    opacity : 1.0;!important;
}
blurfus

It turns out that the opacity channel is inherited

try using the rgba property instead:

background-color: rgba(0, 0, 0, 1); /* red, gree, blue, alpha (opacity) */

Credit: answer adapted from this one

#bg {
  z-index: -1000;
  position: fixed;
  top: 0;
  left: 0;
  opacity: 0.4;
  width: 100%;
  min-height: 100%;
}

.logo,
#logo {
  background-color: rgba(0, 0, 0, 1);
  padding:0;
  margin: 0;
}
<!-- Background -->
<img src="http://lorempixel.com/400/400" id="bg" alt="">

<!-- The image -->
<div class="row">
  <div class="logo">
    <img src="http://lorempixel.com/300/150" width="100%" height="150" id="logo" alt="Title" />
  </div>
</div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Issue with transparent images with a transparent background

Making Background Transparent

Making figure transparent with colored background

Making Linear Layout background transparent

Making a SKScene's background transparent not working... is this a bug?

Setting transparent images background in IrfanView

How to make textview's background transparent when it is the child of the layout

Making a child div non-transparent on top of the transparent div

Making a div transparent and showing background image

Making text background transparent but not text itself

Making text transparent affect background color

Reading border color value form parent's background-color, and transparent parent's background-color

Transparent font on transparent background

Issue with making an overlay hover effect to a PNG image (transparent) in a parent div with a background color

Make the form's background to transparent

Replacing transparent background with white color in PNG images

Cannot apply a transparent background to the a child div

iOS - Make child UIVewController background (of ContainerView) transparent

Make parent div transparent, but only where the child is

Opacity and grayscale filter of background image. Making it black and white and transparent

How to programmatically remove the background of an image making it transparent in android

Making a Semi-Transparent Pause Background screen in Pygame

Making transparent text in CSS and fitting background image inside a text shape

How to do transparent background on few div to see background of parent

Make an image's background transparent or white programmatically

How to set FloatingActionButton's background transparent in flutter?

What's the best implementation for transparent background with progressbar

How can I make the background of UICollection view as transparent without making the cells in it transparent in Swift

Making black pixels transparent