I do not want to inherit the child opacity from the parent in CSS

前端 未结 14 957
猫巷女王i
猫巷女王i 2020-11-21 06:31

I do not want to inherit the child opacity from the parent in CSS.

I have one div which is the parent, and I have another div inside the first div which is the child

14条回答
  •  Happy的楠姐
    2020-11-21 07:05

    Assign opacity 1.0 to the child recursively with:

    div > div { opacity: 1.0 }
    

    Example:

    div.x { opacity: 0.5 }
    div.x > div.x { opacity: 1.0 }
    Example Text - No opacity definition
    Example Text - 50% opacity inherited
    Example Text - 50% opacity not inherited
    Example Text - 50% opacity

提交回复
热议问题