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

前端 未结 14 932
猫巷女王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 07:00

    A little trick if your parent is transparent and you would like your child to be the same, but defined exclusively (e.g. to overwrite the user agent styles of a select dropdown):

    .parent {
         background-color: rgba(0,0,0,0.5);
    }
    
    .child {
         background-color: rgba(128,128,128,0);
    }
    

提交回复
热议问题