Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下内容:
[class^="fa-icon-"], [class*=" fa-icon-"] {
我知道 class^ 意味着以开头,但 class* 是什么意思?
这只是意味着选择其class属性包含子字符串的任何元素fa-icon-
class
fa-icon-
演示
因此,正如我与您分享的演示一样,选择任何p具有子字符串的元素fa-icon-(注意:那里的空间很重要)
p
所以它会选择元素说
<p class=" fa-icon-">Hello</p>
上面的选择器也会选择类似
<p class=" fa-icon-blah">Hello</p>
演示 2
表示具有 class 属性的元素,其值包含至少一个子字符串“fa-icon-”的实例。
从w3c 规范:
[att*=val] 表示具有 att 属性的元素,其值包含至少一个子字符串“val”的实例。如果 "val" 是空字符串,则选择器不代表任何内容。
[att*=val]
表示具有 att 属性的元素,其值包含至少一个子字符串“val”的实例。如果 "val" 是空字符串,则选择器不代表任何内容。