我用来从一些'sattr(data-width)
中获取data-width
-attribute 。list-item
我尝试使用这些值来设置该元素的宽度。
问题是 css 无法将字符串处理为width
/ height
-value。例如:
<foo data-width='100%'></foo>
/* can not work */
foo {
width: attr(data-width)
}
所以我需要将值从-data
属性转换为整数(+单位)。
这有可能吗?