css - 从其父项中排除此子项的格式

标签 css

我有一个如下所示的 CSS,用于在将鼠标悬停在表格上时创建特定的背景颜色。

.cb_table-hover tbody tr:hover td ,
.cb_table-hover tbody tr:hover th {
  background-color: #cfe2e8;  
}

<td> 内我有一个 <div> ,我想从这种悬停颜色疯狂中排除。

<td>
 <div class="override_td">
    {% include '_test_edit.html' %}
 </div>
</td>

所以我想出了一个对初始悬停 css 的否定。

.cb_table-hover tbody tr:hover td:not(.override_td) ,
.cb_table-hover tbody tr:hover th:not(.override_td) {
  background-color: #cfe2e8;  
}

但似乎我已经惨败了,因为我的 Aptana Studio 大声疾呼

The negation pseudo-class, :not(X), is a functional notation taking a simple selector (excluding the negation pseudo-class itself) as an argument. It represents an element that is not represented by its argument. Negations may not be nested; :not(:not(...)) is invalid. Note also that since pseudo-elements are not simple selectors, they are not a valid argument to :not().

Example The following selector matches all button elements in an HTML document that are not disabled. button:not([DISABLED]) The following selector represents all but FOO elements. *:not(FOO) The following group of selectors represents all HTML elements except links. html|*:not(:link):not(:visited)

所以我很困惑为什么它不喜欢我的选择器?

最佳答案

根据 this fiddle,您的选择器看起来格式正确(并遵循 Aptana 警告消息中列出的规则)并且工作正常.您没有提到实际失败(只是 Aptana 的投诉),所以我认为它会正常工作。

Aptana 提示的原因可能是它没有非常仔细地扫描无效的 :not。有可能仅仅因为您的选择器字符串包含两个 :not 伪类,Aptana 就认为它们是无效的,即使它们被逗号分隔也是如此。

关于css - 从其父项中排除此子项的格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13919777/

相关文章:

javascript - 如何在 Angular UI-Select 中自定义组标签

css - 我们可以仅通过 CSS 文件中元素的名称来编写选择器吗?

css - 用scss知道类是否存在

jquery - 是否可以全局文本对齐表列而不在每行中指定类?

html - 是否可以在 HTML 文件中重置 CSS?

html - 如何强制内联 block 元素到父元素的顶部?

javascript - 在 append 方法之后将背景颜色应用于 div

javascript - 存在多个嵌套层时隐藏显示 div

html - 如何让表格单元格具有相同的高度

html - 使用 CSS 创建响应式网格 (100% x 100%)