如何防止跨浏览器的 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 23:29:24  来源:igfitidea点击:

How to prevent CSS declaration dropped errors cross browser?

csscross-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

  1. I'd alwaysput or import IE-specific styles inside a conditonal comment;

  2. 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.

  1. 总是条件注释中放入或导入特定于 IE 的样式;

  2. 作为标准 CSS FF 应该可以使用“字体”,因此只需检查您的语法,例如font: bold 12px/30px Georgia, serif;用空格分隔的值、引号中的多字字体名称等。

回答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 fontit should be taken care of).

隐藏错误并不意味着错误已解决(实际上,如果 FF 显示错误,font则应予以处理)。