为什么 3 位十六进制颜色代码值在 Internet EXPLORER 中的解释不同? [英] Why are 3-digit hex color code values interpreted differently in Internet EXPLORER?

查看:20
本文介绍了为什么 3 位十六进制颜色代码值在 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:

对比

(我知道 bgcolor 已被弃用,它只是方便我完成手头的工作).

(I am aware that bgcolor is deprecated, it was just convenient for what I was accomplishing at hand).

我也知道这是一个错误,可以通过在十六进制代码中附加几个数字(总共 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屋!

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