Possible Duplicate:
What’s the difference in the :not() selector between jQuery and CSS?
如何为类编写CSS选择器'ui-content'
。但它不应该是 id 'ui-container'
的子级?
我尝试在 CSS 中使用以下选择器。
.ui-content:not(#ui-container > .ui-content) {
//styles goes here
}
但它确实可以在 jquery 中工作,例如 $('.ui-content:not(#ui-container > .ui-content)')
,但不是在纯 CSS 中。
如何更正此 CSS 选择器?
所有使用 jquery 的选择器都不适用于纯 CSS 选择器吗?
最佳答案
这很简单:
:not(#ui-container) > .ui-content{
// style
}
您只需要确保没有其他类可以遵守不成为 #ui-container 的要求,但仍然是 .ui-content 的直接父级。
关于jquery - 带有 :not selector working when placed inside as jquery selector, 的 CSS 不是纯 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13252004/