【发布时间】:2012-02-04 21:18:36
【问题描述】:
我的 HTML 文档中有这个:
<a class="wbutton tint" data-tint="rgba(255,0,0,.5)" href="#">This should be red, with an opacity of 0.5</a>
这在 CSS 文件中:
.window > .content .wbutton.tint {
border: solid thin attr(data-tint, color);
box-shadow: inset 0 0 50px attr(data-tint, color);
}
Firefox 在 Firebug 中返回 CSS 错误。我做错了吗?
根据W3C specs for the attr() function,它应该可以工作。
(另外,还有a page about attr() in the MDN Wiki,所以我认为它至少应该可以在 Firefox 中使用)
【问题讨论】:
-
我很确定 "attr()" 不是 CSS3 或任何其他 CSS 的一部分,即使它,CSS3 仍然是一个草案,甚至最新的浏览器也没有完整的还支持。
-
@Hosh Sadiq:是的。看我的回答。
-
attr()目前仅支持content属性,可用于伪元素(如:before、:after)。 -
@RobW 根据 MDN,你指的 attr() 函数是 CSS2.1 的函数,我指的是 CSS3 函数。
-
对 W3C (CSS3) 规范感兴趣的人:dev.w3.org/csswg/css-values/#attr
标签: css