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

前端 未结 14 922
猫巷女王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条回答
  •  悲哀的现实
    2020-11-21 06:54

    Instead of using opacity, set a background-color with rgba, where 'a' is the level of transparency.

    So instead of:

    background-color: rgb(0,0,255); opacity: 0.5;
    

    use

    background-color: rgba(0,0,255,0.5);
    

提交回复
热议问题