10 09/2014

css属性选择器

最后更新: Wed Sep 10 2014 12:29:11 GMT+0800

老忘,再复习一下

[attr] Represents an element with an attribute name of attr.

含有该属性,如 a[class] 匹配所有含 class=”***“ 的元素

[attr=value] Represents an element with an attribute name of attr and whose value is exactly “value”.

匹配 属性=值 完全一致的元素

[attr~=value] Represents an element with an attribute name of attr whose value is a whitespace-separated list of words, one of which is exactly “value”.

值 中包含该 单词(空格分隔的字符串,中文每个字都是单词!)

[attr|=value] Represents an element with an attribute name of attr whose value is a hyphen-separated list of words, one of which is exactly “value”. It can be used for language subcode matches.

值 中包含该 单词(- 减号分隔的字符串) 如: [lang|=en] 匹配 lang=”en-us” 和 lang=”en-uk”

[attr^=value] Represents an element with an attribute name of attr and whose value is the prefixed by “value”.

类似于正则表达式的 ^,以 value 开始。

[attr$=value] Represents an element with an attribute name of attr and whose value is the suffixed by “value”.

类似于正则表达式的 $,以 value 结束。

[attr*=value] Represents an element with an attribute name of attr and whose value contains at least one occurrence of string “value” as substring.

值 中包含该 字符串 就可以(前后可以有其它字母)。

参考文章: