admin管理员组文章数量:1395730
I have a component which renders this kind of html due to using a 3rd party ui component library:
<custom-component class="button-border">
<button>Press me</button>
</custom-component>
I have defined styles for a button element with a class "button-border". Is there a way to make it behave as if the "button-border" class was given directly to the button instead of the parent element?
I have a component which renders this kind of html due to using a 3rd party ui component library:
<custom-component class="button-border">
<button>Press me</button>
</custom-component>
I have defined styles for a button element with a class "button-border". Is there a way to make it behave as if the "button-border" class was given directly to the button instead of the parent element?
Share Improve this question asked Mar 14 at 8:51 weksowekso 852 silver badges13 bronze badges2 Answers
Reset to default 0Yes, apply rules to button: .button-border > button {}
instead of .button-border {}
Answering the CSS question: copy parent class behavior to children - use all: inherit;
:
.parent{
font-style: italic;
cursor: pointer;
color: red;
button{
all: inherit;
}
}
<div class="parent">
<button>Text</button>
</div>
本文标签: CSScopy parent class behavior to childrenStack Overflow
版权声明:本文标题:CSS - copy parent class behavior to children - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744666824a2618582.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论