本文介绍了CSS3的attr()在主要的浏览器中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我在HTML文档中有这个: < a class =wbutton tintdata-tint =rgba (255,0,0,.5)href =#>这应该是红色的,不透明度为0.5< / a> 这在CSS文件中: .window> .content .wbutton.tint { border:solid thin attr(data-tint,color); box-shadow:inset 0 0 50px attr(data-tint,color); } Firefox在Firebug中返回一个CSS错误。我做错了什么? 根据 W3C规范 attr()函数,它应该可以工作。 ,在MDN Wiki 中有一个关于 attr()的页面>,所以我认为它至少应该在Firefox中工作)解决方案看看规范中给出的语法: p> attr(< attr-name>< type-or-unit& fallback>]?) 看起来像属性名称和要使用的单位之间的逗号需要要删除: .window> .content .wbutton.tint { border:solid thin attr(data-tint color); box-shadow:inset 0 0 50px attr(data-tint color); } 然而,即使你有正确的语法, 。结果是没有已知的实现的版本的 attr(),自 2013 2017. To make matters worse, it's still at-risk as of the latest editor's draft of the spec.But not all is lost: if you'd like to see this feature implemented in upcoming browsers, there is still time to suggest it in the relevant feedback channels! Here are the proposals that have been put out so far:Microsoft Edge Platform, currently Under Consideration (ht Lea Verou!)For the record, the basic Level 2.1 version is fully supported across recent versions of all major browsers, including IE8+ and Firefox 2+, and is used with the content property for the :before and :after pseudo-elements for generated content. The Mozilla Developer Network (MDN) browser compatibility table is applicable only to this version, and not the CSS3 version. 这篇关于CSS3的attr()在主要的浏览器中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-28 16:33