Html CSS中透明度的颜色代码是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7851830/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the color code for transparency in CSS?
提问by Safran Ali
Can anyone tell me what is the color code for transparency in CSS like white = "#FFFFFF"? As I am using following code, to convert the color codes into int:
谁能告诉我 CSS 中透明度的颜色代码是什么,例如 white = "#FFFFFF"?当我使用以下代码时,将颜色代码转换为 int:
Color color = ColorTranslator.FromHtml(hex);
return (int)((color.R << 16) | (color.G << 8) | (color.B << 0));
回答by Michael Mior
There is no hex code for transparency. For CSS, you can use either transparent
or rgba(0, 0, 0, 0)
.
没有透明度的十六进制代码。对于 CSS,您可以使用transparent
或rgba(0, 0, 0, 0)
。
回答by Scherbius.com
how to make transparent elements with css:
如何用css制作透明元素:
CSS for IE:
IE 的 CSS:
filter: alpha(opacity = 52);
CSS for other browsers:
其他浏览器的 CSS:
opacity:0.52;
回答by anon
Or you could just put
或者你可以把
background-color: rgba(0,0,0,0.0);
That should solve your problem.
那应该可以解决您的问题。
回答by rob_lowe
Simply choose your background color of your item and specify the opacity separatly:
只需选择项目的背景颜色并单独指定不透明度:
div { background-color:#000; opacity:0.8; }
回答by doctorless
There is no transparency component of the color hex string. There is opacity
, which is a float from 0.0 to 1.0.
颜色十六进制字符串没有透明度组件。有opacity
,它是从 0.0 到 1.0 的浮点数。
回答by tnunes
try using
尝试使用
background-color: none;
that worked for me.
这对我有用。
回答by David
jus add two zeroes (00) before your color code you will get the transparent of that color
只需在颜色代码之前添加两个零 (00),您将获得该颜色的透明
回答by marque
In the CSS write:
在 CSS 中写:
.exampleclass {
background:#000000;
opacity: 10; /* you can always adjust this */
}
回答by Robert Monfera
There are now 8-digit hex codes in CSS4 (CSS Color Module Level 4), the last two digit (or in case of the abbreviation, the last of the 4 digits) represents alpha, 00
meaning fully transparent and ff
meaning fully opaque, 7f
representing an opacity of 0.5 etc.
CSS4 中现在有 8 位十六进制代码(CSS Color Module Level 4),最后两位数字(或者在缩写的情况下,4 位数字中的最后一位)代表 alpha,00
表示完全透明,ff
表示完全不透明,7f
代表一个不透明度为 0.5 等
The format is '#rrggbbaa'
or the shorthand, '#rgba'
.
格式是'#rrggbbaa'
或简写,'#rgba'
.
Support is lacking for MS browsers, they might be less cooperative or just slower than the other developers, either or both of which actually sealed IE's fate: https://caniuse.com/#feat=css-rrggbbaa
缺乏对 MS 浏览器的支持,他们可能比其他开发人员合作得更少或只是速度慢,这两者实际上决定了 IE 的命运:https: //caniuse.com/#feat=css-rrggbbaa
回答by Richard Abrokwah
Simply put:
简单的说:
.democlass {
background-color: rgba(246,245,245,0);
}
That should give you a transparent background.
这应该给你一个透明的背景。