<分区>
我需要使用 CSS content
属性和 :before
伪选择器在它旁边显示对应于每个元素的图像。
我如何以有效的工作方式做类似下面的事情:
content: url("http://example.com/images/" + attr(title));
在 URL 显示图片
"http://example.com/images/523452345"
上面的不行!
<分区>
我需要使用 CSS content
属性和 :before
伪选择器在它旁边显示对应于每个元素的图像。
我如何以有效的工作方式做类似下面的事情:
content: url("http://example.com/images/" + attr(title));
在 URL 显示图片
"http://example.com/images/523452345"
上面的不行!
最佳答案
那是不可能的,这是规范,你不能把 attr() 放在 url() 里面,它们只能互相跟随。
content: normal | none |
[ <string> | <uri> | <counter> | attr() |
open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit
div:before {
content: url("http://example.com/image.jpg") attr(title);
}
关于html - 如何在 CSS 内容属性中混合 url 字符串和属性值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23815657/