为什么3位数的十六进制颜色代码值在Internet EXPLORER中的解释不同? [英] Why are 3-digit hex color code values interpreted differently in Internet EXPLORER?
问题描述
Internet Explorer如何解释它们,以及根据哪种指南或一套标准?
How exactly is Internet Explorer interpreting them, and under which guideline or set of standards?
例如:
#FFF
在Google Chrome中似乎为白色,而在Internet Explorer (我在8和9上测试它)显示为黑色。
is seem as the color white in Google Chrome, for instance, whereas in Internet Explorer (I tested it on 8 and 9) it appears as black.
我用来测试的代码如下:
I code I used to test this was as follows:
< body bgcolor =#ffffff>与< body bgcolor =#fff>
(我知道 bgcolor
已废弃,它只是方便我手头完成的)。
(I am aware that bgcolor
is deprecated, it was just convenient for what I was accomplishing at hand).
我也知道这是一个错误,它可以通过在hexcode中添加几位数字(all-in-all 6)可以很容易地修正,但是我只是想看到科学背后的原因,如果它有一个解释。
I am also aware that this is a bug, and that it can be easily fixed by appending a few digits (all-in-all 6) to the hexcode, but I am just interested in seeing the science behind why it occurs, if there is an explanation for it.
推荐答案
我能够在IE11中重新创建它。如你所知,它是一个不推荐使用的属性。我假设你的网页&浏览器试图将代码解释为HTML5,并且有一个错误在他们的优雅退化来处理这个。
I was able to recreate it in IE11 as well. As you know, it is a deprecated attribute. I assume your webpage & the browser are trying to interpret the code as HTML5 and there is a bug in their graceful degradation to handle this. So it just breaks.
正如@Aaron Vanston指出,使用内联样式或CSS,你仍然可以使用速记十六进制来应用颜色。
As @Aaron Vanston points out, using inline style or CSS, you can still use the shorthand hex to apply a color.
我甚至不会浪费我的时间写出 bgcolor
作为属性。如果我遇到了我正在处理的东西,我会删除它赞成
I wouldn't even waste my time writing out bgcolor
as an attribute. If I came across it in something I was working on, I'd remove it in favor of
style="background-color: #fff"
或CSS替代
body {
background-color: "#fff";
}
这篇关于为什么3位数的十六进制颜色代码值在Internet EXPLORER中的解释不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!