【发布时间】:2014-07-12 00:17:39
【问题描述】:
我需要使用 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);
}
【讨论】: