标题说明了一切。是否有可能使一个元素及其所有子元素失去所有CSS属性?
演示:
<div class="class-defined-but-should-not-affect-the-div">
<!-- content + children -->
</div>
CSS:
.class-defined-but-should-not-affect-the-div {
background-color: green;
}
.class-defined-but-should-not-affect-the-div > .content {
/* tons of other properties */
}
这个例子只是为了让您理解,实际情况有所不同。我想远离CSS属性的元素由大量子元素组成。我无法收集所有的类和ID并撤消效果。我需要一些动态解决方案,可能是通过JS。
编辑:不删除类和id属性。
任何帮助,将不胜感激。
您可以all
对unset
所有属性使用该属性。
body { font-size: small; background-color: #F0F0F0; color:blue; }
blockquote { background-color: skyblue; color: red; }
blockquote { all: unset; }
<blockquote id="quote">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</blockquote> Phasellus eget velit sagittis.
来自链接源的代码段
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句