在 CSS 中对 RGB 颜色值使用十六进制多于十进制有什么好的理由吗? [英] Are there any good reasons for using hex over decimal for RGB colour values in CSS?

查看:22
本文介绍了在 CSS 中对 RGB 颜色值使用十六进制多于十进制有什么好的理由吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

rgb(255,255,255) 表示法从 CSS1 开始可用.但 #ffffff 似乎更受欢迎.

rgb(255,255,255) notation has been available since CSS1. But #ffffff seems to be vastly more popular.

显然它稍微紧凑一些.我知道十六进制与底层字节更密切相关,并且理解对这些值进行算术运算会有优势,但这不是您要使用 CSS 做的事情.

Obviously it's slightly more compact. I know that hex is more closely related to the underlying bytes, and understand that there would be advantages in carrying out arithmetic on those values, but this isn't something you're going to do with CSS.

颜色值往往是由设计者(比如我自己)创造的,他们在其他任何地方都不会遇到十六进制表示法,并且更熟悉十进制表示法,这是在他们使用的应用程序中指定颜色的主要方式——在事实上,我遇到过很多人没有意识到给定的十六进制值如何分解为 RGB 分量,并假设它根本与颜色没有直接关系,就像 Pantone 颜色系统参考(例如 PMS432).

Colour values tend to be originated by designers (such as myself) who would never encounter hex notation anywhere else, and are much more familiar with the decimal notation which is the main way of specifying colour in the apps they use -- in fact I have met quite a few who don't realise how a given hex value breaks down into RGB components and assumed it didn't directly relate to the colour at all, like a Pantone colour system reference (eg PMS432).

那么,有什么理由不使用十进制?

So, any reason not to use decimal?

推荐答案

十六进制值更容易从您喜欢的图像编辑器中复制和粘贴.

Hex values are easier to copy and paste from your favourite image editor.

RGB 值更易于使用 Javascript 操作.

RGB values are easier to manipulate with Javascript.

(我最喜欢的十六进制颜色值是#EDEDED,我们为参与赛车运动的客户制作的网站的背景颜色为#F1F1F1 :-)

(My favourite Hex colour value is #EDEDED and a site we made for a client involved in motorsport had a background colour of #F1F1F1 :-)

编辑

这篇关于在 CSS 中对 RGB 颜色值使用十六进制多于十进制有什么好的理由吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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