使用HTML属性作为CSS属性值

使用HTML属性作为CSS属性值,第1张

概述参见英文答案 > CSS3’s attr() doesn’t work in major browsers                                    4个 规范说: The attr() function returns the value of an attribute on the element for use as a value in a property. 参见英文答案 > CSS3’s attr() doesn’t work in major browsers4个
规范说:

The attr() function returns the value of an attribute on the element for use as a value in a property. If used on a pseudo-element,it returns the value of the attribute on the pseudo-element’s originating element.

http://www.w3.org/TR/css3-values/#attr

但是,这似乎不起作用.当我使用background-image:url(attr(href));我得到字符串“attr(href)”作为属性值,而不是值本身.

http://jsfiddle.net/x2Rpt/1/

有什么想法为什么会被打破?

解决方法 它没有被打破;只是没有浏览器实现了 the CSS3 version of attr().目前,只有 introduced in CSS2.1的实现存在,实现仅限于生成和替换内容的内容属性.

除非对规范进行更改,否则您的语法似乎是正确的.

总结

以上是内存溢出为你收集整理的使用HTML属性作为CSS属性值全部内容,希望文章能够帮你解决使用HTML属性作为CSS属性值所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1138845.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)

保存