在CSS中获取属性的值 [英] Get value of attribute in CSS
本文介绍了在CSS中获取属性的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个HTML代码:
I have this HTML code:
<div data-width="70"></div>
我想设置CSS的宽度等于data-width属性的值,例如。类似这样:
I want to set it's width in CSS equal to the value of data-width attribute, e.g. something like this:
div {
width: [data-width];
}
我看到这是在某个地方完成的,但我不记得了。非常感谢。
I saw this was done somewhere, but I can't remember it. Thanks.
推荐答案
好吧,伙计们,这是我要找的:
Okay, guys, this is what I was looking for:
https://developer.mozilla.org/en-US / docs / Web / CSS / attr
问题是即使某些主流浏览器(在这种情况下是Chrome)也不支持它。
The problem is that it's not supported even by some of the major browsers, in this case Chrome.
感谢那些试图帮助的人。
Thanks those who tried to help anyway.
这篇关于在CSS中获取属性的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文