jQuery导致Firefox框大小警告 [英] jQuery causes Firefox box-sizing warnings

查看:119
本文介绍了jQuery导致Firefox框大小警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有WebDeveloper扩展,我得到一个CSS警告,所以我去调查它。警告是以下3个:

I have the WebDeveloper extension and I got a CSS warning so I went to investigate it. The warning is 3 of the following:

Warning: Unknown property 'box-sizing'.  Declaration dropped.
Line: 0

然后我创建了一个空白文件,注意到它不存在。几分钟后,我发现了一个可重现的原因:包括jQuery 1.9.1脚本!

Then I made a blank file and noticed it wasn't there. A few minutes later I found a reproducible cause: including the jQuery 1.9.1 script!

我能做什么或应该做什么?我想使用jQuery,但我觉得有点烦人,我会永远看到我的工具栏中的CSS警告。

What can or should I do? I want to use jquery but I find it a bit annoying that I'll forever see CSS warnings in my toolbar.

<!DOCTYPE html>
<html>
<head></head>
<body>
<div>Empty</div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</body>
</html>


推荐答案

选项 >

Options


  1. 使用jQuery 1.7.2。

  2. 提出jQuery小组的问题,

  3. 使用Firebug代替WebDeveloper(可能或可能不会帮助)。

  4. 忽略它。

  1. Use jQuery 1.7.2.
  2. Raise the issue with the jQuery team and hope for a fix (or provide one yourself).
  3. Use Firebug instead of WebDeveloper (which may or may not help).
  4. Ignore it.

只要页面呈现正确,我相信这是一个警告,你可以安全地忽略,即使你正在建立一个网站,严格要求验证CSS 。

As long as the page renders correctly, I believe this is a warning you can safely ignore, even if you're building a website that strictly requires validating the CSS.

当Firefox完全支持 box-sizing 时,警告应该消失code> -moz - 前缀),但是直到Firefox 21之后的某个版本才会发生。

The warnings should go away as soon as Firefox has full support for box-sizing (without requiring the -moz- prefix), but that won't happen until some version after Firefox 21.

info

Background info

警告来自某些CSS样式所需的不同语法。要支持所有浏览器,您通常必须指定所有各种语法。

The warning arises from the different syntaxes needed for certain CSS styles. To support all browsers, you generally have to specify all of the various syntaxes. Browsers will ignore the ones they don't recognize.

box-sizing 的情况下,Firefox需要 -moz - 前缀,早期版本的Safari Mobile和Android浏览器需要 -webkit - 前缀和其他浏览器根本不需要前缀:

In the case of box-sizing, Firefox requires the -moz- prefix, early versions of Safari Mobile and the Android browser require the -webkit- prefix, and other browsers require no prefix at all:

-webkit-box-sizing: content-box;
   -moz-box-sizing: content-box;
        box-sizing: content-box;

添加线性渐变时出现类似的问题,在这种情况下,由值而不是属性name:

A similar issue arises when adding a linear gradient, in this case caused by the value rather than the property name:

background-image: -webkit-linear-gradient(top, #444, #999);
background-image:    -moz-linear-gradient(top, #444, #999);
background-image:     -ms-linear-gradient(top, #444, #999);
background-image:      -o-linear-gradient(top, #444, #999);
background-image:         linear-gradient(top, #444, #999);

当使用不同语法出现警告时,通常情况下验证器或错误控制台足够聪明地识别一个真正的问题从一个无害的,通常是不可避免的。

When warnings arise from the different syntaxes used, it's typically a case of the validator or error console not being smart enough to recognize a real problem from a harmless one that's often unavoidable. And to be fair, it is in fact identified as a warning, not an error.

其他信息

新版本的jQuery使用 box-sizing 样式作为内部用途。 jQuery 1.8.0只生成一个 box-sizing 警告,jQuery 1.7.2不生成。

Newer versions of jQuery make use of the box-sizing style for internal purposes. jQuery 1.8.0 only produces a single box-sizing warning, and jQuery 1.7.2 produces none.

jQuery可能会以一种略有粗心的方式使用它 - 没有先测试,如果有一些类型的支持,但没有做任何实际的伤害。如果是这样,如果有足够的人向jQuery团队投诉,jQuery代码可能会被重构以解决这个问题(以jQuery运行速度稍慢一点为代价)。

jQuery may be using it in a slightly-careless way -- without first testing if there's some type of support for it -- but without doing any actual harm. If so, if enough people complain about it to the jQuery team, the jQuery code could potentially be refactored to address this (at the cost of jQuery running a tiny bit slower).

如果警告是关于 -moz-box-sizing 而不是 box-sizing ,这将更可能建议Firefox的一个可能的错误,而不是jQuery的一个小问题。

If the warning were about -moz-box-sizing rather than box-sizing, that would more likely suggest a possible bug with Firefox rather than a minor issue with jQuery.

这篇关于jQuery导致Firefox框大小警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆