1

My code is like this

<body style="background: url('im.jpeg')">
<div class="inner" style="opacity:0.5;margin-left:20px">
  <div class="innermost">
  <p>My content</p>
  </div>
</div>   
</body>

The problem with my code is that it body has an image so that it would be on full screen and class "innermost" has original content including pics and texts , opacity is assigned to "inner" class. And this opacity affects all element of "innermost". Is there any solution to prevent opacity of "innermost" class without affecting body style. Thanks for reading.

Update

is there any other alternative of my code , such that i can have image on full screen.

rickj
  • 210
  • 2
  • 11

3 Answers3

2

It is not going to happen the way you want. If innermost is inside inner, it is part of its content, and will be transparent too. Depending on what you want to achieve, you can apply an alternative. For example, a transparent background. Or remove innermost from inner, and use position absolute:

<div style="position:relative;margin-left:20px">
    <div class="inner" style="opacity:0.5;">

    </div>
    <div class="innermost" style="position:absolute; left:0; top:0;">
        <p>My content</p>
    </div>
</div>  
Hugo Silva
  • 6,748
  • 3
  • 25
  • 42
1

I think you can try to add css property "style: none" for your class "innermost". Doing that, you "stop" the opacity specified below.

0

If a parent element has an opacity value set at, say, 0.5, all of its children will inherit that opacity setting, and there’s no way to reverse that opacity on the child elements. Read this http://www.impressivewebs.com/fixing-parent-child-opacity/