how to cancel opacity for a child element?
问题 I want apply opacity for parent but I do not want the child element to inherit this opacity. <div class=\"parent\"> <div class=\"child\"></div> </div> .parent { opacity: 0.6; } Is there a way to \"cancel\" the inherited opacity? maybe force it to opacity=1 for the child element? 回答1: The opacity of the child will always be the opacity of the parent if the opacity of the child is 1. This is not a problem with inheritance, but rather with the way opacity is calculated. For instance, <div id=