十六进制颜色:“透明”的数字表示法 [英] Hex colors: Numeric representation for "transparent"?

查看:1447
本文介绍了十六进制颜色:“透明”的数字表示法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一个网站CMS,用户可以在其中为特定网站元素选择颜色。
我想将所有颜色值转换为十六进制,以避免任何进一步的格式化麻烦(rgb(x,y,z)或命名的颜色)。我找到了一个很好的JS库。



我不能进入十六进制的唯一的事情是透明。我需要这个当显式地声明一个元素为透明,这在我的经验可以不同于没有定义任何值。



有人知道这是否可以变成一些数字形式?是否必须设置所有处理实例以接受十六进制值transparent?

解决方案

透明度是颜色本身之外的属性,也称为 alpha 组件。



如果你想要一个透明的背景,你可以这样做:



<$> p $ p> background:transparent;

此外,我不知道这是否有帮助, code> opacity 属性:

  .half {
opacity:0.5;
filter:alpha(opacity = 50);
}

您需要两者才能使它在IE和所有其他正派的浏览器。


I am building a web CMS in which the user can choose colours for certain site elements. I would like to convert all colour values to hex to avoid any further formatting hassle ("rgb(x,y,z)" or named colours). I have found a good JS library for that.

The only thing that I can't get into hex is "transparent". I need this when explicitly declaring an element as transparent, which in my experience can be different from not defining any value at all.

Does anybody know whether this can be turned into some numeric form? Will I have to set up all processing instances to accept hex values or "transparent"? I can't think of any other way.

解决方案

Transparency is a property outside the color itself, also known as alpha component. You can't code it as RGB.

If you want a transparent background, you can do this:

background: transparent;

Additionally, I don't know if it might be helpful or not but, you could set the opacity property:

.half{
  opacity: 0.5;
  filter: alpha(opacity=50);
}

You need both in order to get it working in IE and all other decent browsers.

这篇关于十六进制颜色:“透明”的数字表示法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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