Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Opacity of Parent and Child

  • This topic is empty.
Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #38433
    Manojsethi
    Participant

    I don’t want to inherit the opacity of the parent class in the child class. so please help me.

    #104131
    Taufik Nurrohman
    Participant

    Maybe with rgba or hsla color code.

    #104177
    ylc66
    Participant

    Hompimpa is right.

    some clue with this ?

    #104228
    Manojsethi
    Participant

    I got without rgba why to move in css2 when we have css3

    #104262
    Manojsethi
    Participant

    it’s possible with opacity tag in css3 using positining. I got it with css3.

    #104302
    ylc66
    Participant

    how did you do this ?

    #104304

    @Manojsethi That sounds like an incredibly ugly hack, and probably indicates that you should tackle the problem another way.

    #104333
    Manojsethi
    Participant

    i will share my code here tomorrow.

    #104335
    Paulie_D
    Member

    A link would be better.

    #104348

    Hi, Manojsethi. This is actually a pretty easy task once you figure it out. I know this because I once had the same issue! Also does not require any trickery or hacks.

    What you are probably trying to do is something along the lines of this:

    #someParent {
    opacity: .5;
    }

    You would probably expect this to work, but sadly, it doesn’t.

    What you need to do, would be something like what I have below:

    #someParent {
    background: rgba(0,0,0,0.5);
    }

    What the above css does, is set an RGB colour on the parent element and change its opacity.

    The first 3 zeros represent your colour choice in their RGB codes. The third nuber (the 0.5) represents the alpha transparency (opacity) of that colour.

    So, if you ever need to effect only the parent element on a web page, make sure to use rgba.

    I hope that has helped!

    -Mike

    #141600
    overtly
    Member

    ^Mike, thanks so much! Was looking everywhere for this and your solution works perfectly.

    #141799
    PicnicTutorials
    Participant

    1

    #141800
    PicnicTutorials
    Participant

    This editor blows. I give up

    #246090
    Saurabh Raja
    Participant

    Thanks much! I have been applying rgba to child element while setting back color and opacity attributes for parent and wondering why wouldn’t it work! Thanks again for the solution.

Viewing 14 posts - 1 through 14 (of 14 total)
  • The forum ‘CSS’ is closed to new topics and replies.