CSS 中的独立属性选择器
Standalone attribute selector in CSS
我正在使用独立的属性选择器,因为我发现 AMCSS. Recently I switched to cssnext from Compass and discovered that syntax highlighting seems to be broken in Atom 和我测试过的其他一些 places/apps。
/* So this thing will be highlighted properly */
h1[foo] { font-weight: bold; }
/* and this thing not */
[foo] { font-weight: bold; }
奇怪的是我在规范中找不到任何独立属性选择器的例子,但它们工作得很好。所有示例都使用组合选择器,如 h1[foo]
。
TL;DR
[foo]
是否与*[foo]
相同并且可以安全使用,还是只是巧合?
使用 h1[foo]
与 [foo]
等同于 h1.bar
与 .bar
。
我正在使用独立的属性选择器,因为我发现 AMCSS. Recently I switched to cssnext from Compass and discovered that syntax highlighting seems to be broken in Atom 和我测试过的其他一些 places/apps。
/* So this thing will be highlighted properly */
h1[foo] { font-weight: bold; }
/* and this thing not */
[foo] { font-weight: bold; }
奇怪的是我在规范中找不到任何独立属性选择器的例子,但它们工作得很好。所有示例都使用组合选择器,如 h1[foo]
。
TL;DR
[foo]
是否与*[foo]
相同并且可以安全使用,还是只是巧合?
使用 h1[foo]
与 [foo]
等同于 h1.bar
与 .bar
。