/* Hexadecimal value with color and 100% transparency*/
background-color: #11ffee00; /* Fully transparent */
/* Special keyword values */
background-color: transparent;
/* HSL value with color and 100% transparency*/
background-color: hsla(50, 33%, 25%, 1.00); /* 100% transparent */
/* RGB value with color and 100% transparency*/
background-color: rgba(117, 190, 218, 1.0); /* 100% transparent */
4
讨论可能有点晚,但不可避免地会有人像我一样偶然发现这篇文章 . 我找到了我正在寻找的答案,并认为我是透明的 . Jerska 's mention of the transparency attribute for the div'的CSS是解决方案:http://jsfiddle.net/jyef3fqr/
5 回答
不透明度为您提供半透明或透明度 . 查看示例Fiddle here .
注意:these are NOT CSS3 properties
见http://css-tricks.com/snippets/css/cross-browser-opacity/
opacity
的问题在于它也会影响内容,而通常你不希望这种情况发生 .如果你只想让你的元素透明,它就像下面这样简单:
但如果你想要它的颜色,你可以使用:
或者使用右侧
alpha
定义背景图像(1px
,1px
) .(为此,请使用
Gimp
,Paint.Net
或任何其他允许您执行此操作的图像软件 .只需创建一个新图像,删除背景并在其中放入半透明颜色,然后将其保存在png中 . )
正如René所说,最好的办法是混合使用
rgba
和1px
by1px
图像作为后备,如果浏览器不支持alpha:See also :http://www.w3schools.com/cssref/css_colors_legal.asp .
Demo :My JSFiddle
transparent 是 background-color 的默认值
http://www.w3schools.com/cssref/pr_background-color.asp
来自https://developer.mozilla.org/en-US/docs/Web/CSS/background-color
设置背景颜色:
讨论可能有点晚,但不可避免地会有人像我一样偶然发现这篇文章 . 我找到了我正在寻找的答案,并认为我是透明的 . Jerska 's mention of the transparency attribute for the div'的CSS是解决方案:http://jsfiddle.net/jyef3fqr/
HTML:
CSS:
JS:
我最初的灵感来源:http://jsfiddle.net/5g1zwLe3/我还使用paint.net创建了透明BG的透明PNG 's, or rather the PNG' .