如何防止跨浏览器的 CSS 声明丢失错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4707747/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to prevent CSS declaration dropped errors cross browser?
提问by John
Hi I would like to know how to easily prevent dropped errors from appearing from debugging software such as webdeveloper plugin in Firefox. I get errors such as:
嗨,我想知道如何轻松防止从调试软件(例如 Firefox 中的 webdeveloper 插件)中出现丢弃的错误。我收到错误,例如:
Warning: Error in parsing value for 'filter'. Declaration dropped.
警告:解析“过滤器”的值时出错。宣言落下。
Warning: Error in parsing value for 'font'. Declaration dropped.
警告:解析“字体”的值时出错。宣言落下。
I understand I get these errors because Firefox does not support these CSS properties, but how do I drop them before hand so Firefox does not attempt to read them in the first place? I know I can create a separate style sheet for every browser but that is a inconvenience. Is there a simple solution?
我知道我收到这些错误是因为 Firefox 不支持这些 CSS 属性,但是我如何事先删除它们,以便 Firefox 不会首先尝试读取它们?我知道我可以为每个浏览器创建一个单独的样式表,但这很不方便。有简单的解决方案吗?
采纳答案by Dave Everitt
I'd alwaysput or import IE-specific styles inside a conditonal comment;
as standard CSS FF should be fine with 'font', so just check your syntax e.g.
font: bold 12px/30px Georgia, serif;
values separated by spaces, multi-word font names in quotes, etc.
回答by kapa
If you are using an IE-specific declaration (like filter
), put it in an IE-specific stylesheet. It is simple and easy, and I don't really understand why it would be an incovenience (the inconvenience is IE itself).
如果您使用特定于 IE 的声明(如filter
),请将其放在特定于 IE 的样式表中。它简单易行,我真的不明白为什么会带来不便(不便之处在于 IE 本身)。
Hiding an error does not mean the error is solved (and actually if FF shows an error in font
it should be taken care of).
隐藏错误并不意味着错误已解决(实际上,如果 FF 显示错误,font
则应予以处理)。