我有一个班级:
li:before {
margin: 0 5px 0 -15px;
color: #005984;
content: "■";
}
但是如果它被一个带有class =" k-list"
的元素包含在内,我就不希望它被应用<ABC class="k-list">
not applied here
</ABC>
如何添加:不是上面的css?
答案 0 :(得分:0)
如果元素包含在类.k-list
的元素中,那么最好的方法是覆盖添加到元素中的内容:
li:before {
margin: 0 5px 0 -15px;
color: #005984;
content: "■";
}
.k-list li:before {
display: none;
}
如果由于某种原因,您想确保DOM中至少有一个较高元素没有类k-list
(包括html和body):
*:not(.k-list) li:before {
margin: 0 5px 0 -15px;
color: #005984;
content: "■";
}
但是,如果你知道自己想要开始这样的搜索,那么它可能会更加具体和有用:
body *:not(.k-list) li:before {
margin: 0 5px 0 -15px;
color: #005984;
content: "■";
}
上述CSS将排除body元素未包含的任何元素满足*:not(.k-list)
条件。