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

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

问题描述

rgb(255,255,255)符号。但 #ffffff 似乎更受欢迎。



显然,它更紧凑。我知道十六进制与底层字节更紧密相关,并且理解在对这些值进行算术时会有优势,但这不是你要用CSS。



颜色值通常由设计师(如我自己)创造,他们永远不会遇到十六进制符号,而且更熟悉十进制符号,这是在应用程序中指定颜色的主要方式他们使用 - 事实上,我遇到了很多人不知道一个给定的十六进制值如何分解成RGB组件,并假设它不直接与颜色相关,如Pantone色系统参考(例如PMS432 )。



那么,任何理由不使用decimal?

解决方案



使用Javascript可以更容易地处理RGB值。



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




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

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.

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 values are easier to manipulate with Javascript.

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

Ed.

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

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