6

我目前维护的项目中的许多 CSS 属性都以插入符号开头,^如下所示:

<tr style="^padding-bottom: 10px;">

插入符号有任何意义吗?也许修复一些不起眼的浏览器?或者它只是以前开发人员的错字,已经复制粘贴了 x 次(因为它总是与“填充底部”一起存在)?

4

2 回答 2

6

前面带有插入符号的样式不会被应用。因此,在这种情况下,它可能是一种注释CSS 样式的方法,而不必使用整个 HTML 注释。不过,这不是标准的方法。

(例子)


CSS 中的插入符号确实有意义,“Begins With”属性选择器

它允许您根据属性值是否以给定字符串开头来定位 CSS 中的元素。

E[foo]  an E element with a "foo" attribute
E[foo="bar"]    an E element whose "foo" attribute value is exactly equal to "bar"
E[foo~="bar"]   an E element whose "foo" attribute value is a list of whitespace-separated values, one of which is exactly equal to "bar"
E[foo^="bar"]   an E element whose "foo" attribute value begins exactly with the string "bar"
E[foo$="bar"]   an E element whose "foo" attribute value ends exactly with the string "bar"
E[foo*="bar"]   an E element whose "foo" attribute value contains the substring "bar"

但是,在您的情况下,插入符号不能用作选择器。

于 2012-08-02T07:16:33.020 回答
4

是的,插入符号在 CSS 3 中有意义,它是 CSS 3 中的属性选择器。此选择器允许表示元素的属性。When a selector is used as an expression to match against an element, attribute selector must be considered to match an element if that element has an attribute that matches the attribute represented by the attribute selector .

但在你的情况下,它可能是一个错字。

CSS3 属性选择器 - 子字符串匹配

CSS3 规范中的三个属性选择器允许您检查指定属性的值以进行字符串匹配。这些属性选择器称为子串匹配属性选择器

[att^=val]

表示具有 att 属性的元素,其值以前缀“val”开头。如果 "val" 是空字符串,则选择器不代表任何内容。

[att$=val]

表示具有 att 属性的元素,其值以后缀“val”结尾。如果 "val" 是空字符串,则选择器不代表任何内容。

[att*=val]

表示具有 att 属性的元素,其值包含至少一个子字符串“val”的实例。如果 "val" 是空字符串,则选择器不代表任何内容。

于 2012-08-02T07:19:58.847 回答