admin管理员组文章数量:1128329
I am developing an interactive data visualization library and CSS inheritance has been causing me some pain. Specifically, I'd like my interactive graphs to be embedable inside HTML documents (such as bookdown) without inheriting the parent element's styles, since this can mess up my layout. I'm using Tailwind utility classes and have had issues where the parent component's styles would override my graphs' styles because they had higher specificity.
Is there a way to create barrier between the styles of the parent component and my components, such that my components would not inherit any of the parent's styles? Particularly one that would work with Tailwind utility classes? Suppose I have the following HTML:
<div id="parent-component">
<div id="my-root-component">
<div id="my-child-component1"></div>
<div id="my-child-component2"></div>
...
</div>
</div>
I don't want anything bellow my-root-component
to inherit the parent-component
's (and it's ancestors') styles. As per similar post and this article, I've tried the following:
.my-root-component {
all: revert;
* {
all: revert;
}
}
This seems to partially work, however, it overrides the Tailwind utility classes of the child components too. Any idea how to create a barrier to inheritance while also retaining the ability to add Tailwind classes?
本文标签: Create a barrier to CSS inheritance with TailwindStack Overflow
版权声明:本文标题:Create a barrier to CSS inheritance with Tailwind? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736720676a1949449.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论