【发布时间】:2017-03-03 11:28:43
【问题描述】:
有没有办法选择一个没有应用了特定 CSS 属性内联(独立于值)的元素?
.element:not([background-color^="rgb"]){}
.element:[background-color=""]{}
【问题讨论】:
标签: css attributes css-selectors
有没有办法选择一个没有应用了特定 CSS 属性内联(独立于值)的元素?
.element:not([background-color^="rgb"]){}
.element:[background-color=""]{}
【问题讨论】:
标签: css attributes css-selectors
attribute 是 样式 而不是 CSS property(在本例中为背景色)。
-使用CSS3 [attribute^=value] 选择器,值以单词(“background-color”)开头:
.element:not([style^="background-color"]){}
-使用CSS [attribute~="value"] 选择器,该值包含一个指定的单词(“background-color:”),在值的任何部分,但整个单词:
.element:not([style~="background-color:"]){}
-使用 CSS [attribute|="value"] 选择器,该值必须是一个完整的单词,可以单独使用,如 class="top",也可以后跟连字符(- ):
.element:not([style|="background"]){}
-使用CSS [attribute*="value"] 选择器,值包含一个指定的值(字母),在它的任何部分:
.element:not([style*="background"]){}
【讨论】: