我可以检测较旧的显示器并为其提供网络安全颜色吗?
我想在网站上的多个位置使用非网络安全颜色,包括背景颜色。但我担心使用旧电脑的访客。
如果访问者看不到非网络安全颜色,我是否可以使用任何代码将颜色从非网络安全颜色更改为最接近的网络安全颜色?
I want to use non-web-safe colors in several places on my website, including for the background. But I am concerned about visitors with older computers.
Is there any code I can use that will change the color from the non-web-safe color to the nearest web-safe color if the visitor cannot see non-web-safe colors?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,这个问题无法用简单的 HTML 来回答,因此我发布此 JavaScript 解决方案以提供替代方法:
可以使用 screen.colorDepth 返回颜色深度(以位为单位) ,用户屏幕的。 Firefox 3.x 和 4.1(测试版)中的错误/错误实现除外。
关于 PPK 的附录,Chromium 11/Ubuntu 11.04 也返回
24
而不是32
,因此 Firefox 可能有是正确的。JS Fiddle 演示。
参考:
As this question cannot, to my knowledge, be answered with simple HTML, I'm posting this JavaScript solution to offer an alternative means:
It's possible to use
screen.colorDepth
to return the color depth, in bits, of the user's screen. With the exception of a faulty/erroneous implementation in Firefox 3.x and 4.1 (beta).Addenda with respect to PPK, Chromium 11/Ubuntu 11.04 also returns
24
rather than32
, so Firefox may have been correct.JS Fiddle demo.
Reference:
我可能在这里弄错了,但网络安全颜色的目的是让您的图像在颜色深度较低(例如 8 位颜色)的显示器上看起来与在颜色深度较高的显示器上看起来相同( 16/24 位颜色)。之所以会发生这种情况,是因为所有这些颜色(理论上)应该能够以所有颜色格式显示。
如果您有一个不“网络安全”的图像,并且您在具有 8 位颜色的系统上查看它,则所有不适合显示器颜色功能的颜色都应自动显示为最接近的颜色很合适。基本上,您不必“转换”它。颜色的位深度不允许它显示任何其他颜色,因此它必须将某些内容放入其中,其中应该是下一个最接近的显示颜色。
也就是说,网络安全颜色是从显示器仅使用 8 位颜色开始的。我不认为这是你现在真正需要担心的事情,除非你知道你的观众正在使用非常非常旧的技术。
I may be mistaken here, but the point of web-safe colours was so that your images will look the same on a monitor with a lower colour depth (eg. 8-bit colour) as they would on one with a higher color depth (16/24-bit colour). Which would happen because all of those colours should (theoretically) be able to be displayed in all colour formats.
If you have an image that is not "web-safe", and you view it on a system with 8-bit colour, all of the colours that don't fit within the display's colour capabilities, should automatically be displayed as the closest colour that fits. Basically, you don't have to "convert" it. The bit depth of the colour doesn't allow it to display any OTHER colours and so it'll have to sub something in, which should be the next closest display colour.
That said, web-safe colours are from the time when displays only used 8-bit colour. I don't think that this is something you really have to worry about now unless you know that your audience is using very, very, old technology.
如果您使用十六进制/颜色代码而不是图像,浏览器将自动执行此操作。对于图像,他们只会犹豫不决,优雅地降低他们没有工作的体验。
http://www.limov.com/colour /何时使用-web-safe-palette.lml
The browser will automatically do this if your using hex/color codes and not images. And with images they will just dither, graceful degrading their experience with no work.
http://www.limov.com/colour/when-to-use-the-web-safe-palette.lml