CSS attr() - 在之前/之后动态设置FontAwesome字形

Luc*_*rdi 3 html css attributes attr font-awesome

我试图通过CSS属性attr(property)在span或按钮内动态设置FontAwesome字形.

我想要的是在标签上设置属性

<button glyph="\f005"></button>
Run Code Online (Sandbox Code Playgroud)

然后像这样在CSS文件中使用它

button::before{
     content: attr(glyph)
}
Run Code Online (Sandbox Code Playgroud)

但它看起来不起作用,只显示我在标签中写的代码.有没有办法"渲染"代码或使CSS将其视为转义字符?

快来看看这个小提琴吧.

ten*_*oin 5

尝试将glyph属性的值设置为HTML实体,例如 glyph="&#xf005;"