-1

I have set opacity on the outer wrapper to (0.5). However, this sets all the inner elements' opacity to (0.5) also. How can I make it so that the inner elements have an opacity of 1? Thanks!

//..The HTML..//

<div class="nav-wrapper">

    <div class="circle1"></div>
    <div class="circle2"></div>
    <div class="circle3"></div>
    <div class="circle4"></div>
    <div class="circle5"></div>

 </div>

//..The CSS..//

.circle1 {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #BBBBBB;
}

.nav-wrapper {
    height: 100%;
    width: 100%;
    top: 0;
    opacity: 0.5;
    background: white;
}
Lord Goderick
  • 965
  • 2
  • 14
  • 32
  • 1
    Possible duplicate of [I do not want to inherit the child opacity from the parent in CSS](http://stackoverflow.com/questions/5770341/i-do-not-want-to-inherit-the-child-opacity-from-the-parent-in-css) – CBroe Nov 19 '16 at 12:34
  • why opacity on a white element? is there a background image? with your code there is no need for opacity – Sebastian Brosch Nov 19 '16 at 12:34

3 Answers3

3

You should use a rgba background instead of opacity for the nav-wrapper

.nav-wrapper {
    height: 100%;
    width: 100%;
    top: 0;
    //opacity: 0.5;
    //background: white;
    background: rgba(255,255,255, 0.5);
}
Marileen
  • 179
  • 1
  • 6
2

You can't. This is not how opacity works. Use background: rgba(255,255,255,0.5); instead. (rgba(); is color with RGB, and opacity)

junkfoodjunkie
  • 3,168
  • 1
  • 19
  • 33
1

Here is JSFiddle

When you give background and opacity property to parent div then it also affects to its child divs. that's why you need to use background:rgba(red,green,blue,alpha_value)

You can refer here

Bhavin Shah
  • 2,462
  • 4
  • 22
  • 35