使用HTML5数据属性的CSS值 [英] CSS values using HTML5 data attribute
问题描述
宽度:ATTR(数据宽度);
我想知道是否有任何方式有可能使用HTML5的数据设置一个CSS值 -
属性可以设置CSS以同样的方式内容
。目前,这是行不通的。
HTML
< DIV数据宽度=600px的>< / DIV>
CSS
DIV {宽度:ATTR(数据宽度)}
有的确是这样的功能prevision,看<一个href=\"http://www.w3.org/TR/css3-values/#attr-notation\">http://www.w3.org/TR/css3-values/#attr-notation
这小提琴应该像你所需要的,但不会现在。
不幸的是,它仍然是一个草案,并没有在主流浏览器全面实施。
它为内容
伪元素的工作,虽然。
width: attr(data-width);
I want to know if there's any way it's possible to set a css value using HTML5's data-
attribute the same way that you can set css content
. Currently it doesn't work.
HTML
<div data-width="600px"></div>
CSS
div { width: attr(data-width) }
There is, indeed, prevision for such feature, look http://www.w3.org/TR/css3-values/#attr-notation
This fiddle should work like what you need, but will not for now.
Unfortunately, it's still a draft, and isn't fully implemented on major browsers.
It does work for content
on pseudo-elements, though.
这篇关于使用HTML5数据属性的CSS值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!