0

In my header div, I want to put opacity .75, however, I do not want to change the opacity of my logo which is placed in the div. Whenever, I put opacity to the whole div, it changes opacity of the logo as well. Can anyone help me in this regard?

shumana chowdhury
  • 1,742
  • 2
  • 14
  • 34

3 Answers3

7

Try like this:

div{
    background-color:rgba(0,0,0,.5);
}
blex
  • 24,941
  • 5
  • 39
  • 72
G.L.P
  • 7,119
  • 5
  • 25
  • 41
0

You can give each div a class like so:

HTML

<div class="header">
    <div class="logo">Logo</div>
</div>

CSS

.header {
    width: 100%
    height: 500px;
    background-color: rgba(0,0,0,.5);
}
.logo {
    display: inline-block;
    width: 100px;
    height: 100px;
    background-color: #000;
    color: #fff;
}

You can see an example, here.

Sam
  • 1,401
  • 3
  • 26
  • 53
0

Just to add to his here is another solution that will work with a transparent png logo

HTML:

<div class="wrapper">
    <img src="http://upload.wikimedia.org/wikipedia/en/2/2d/SRU-Logo-Transparent.png" />
</div>

CSS:

.wrapper {
    cursor:pointer;
    transition:all 400ms ease-in;
}

.wrapper:hover {
   background:powderBlue;
    transition:all 400ms ease-in;
}

.wrapper img {
    width:100%;
}

JSFIDDLE

Or you can change the hover effect to rgba css

.wrapper:hover {
    background:rgba(0,0,0,0.75);
}

Or use a 1px png

.wrapper:hover {
   background:url("/path/to/transparent.png") repeat;
}
lharby
  • 3,057
  • 5
  • 24
  • 56