Html 如何在div上设置部分透明的背景?

Html 如何在div上设置部分透明的背景?,html,css,Html,Css,我希望div是部分透明的,这样背景就可以看穿,但希望其他元素不像图像中那样透明。目前我使用的是不透明度:.4 HTML 屏幕截图: 使用rgba颜色,而不是影响元素子元素的不透明度 比如说 background-color: #AEABA1 opacity: .4 将转化为: background-color: rgba(174, 171, 161, 0.4) 您可以为类找到一个十六进制到RGBA的转换器。tarifas_left_top和。tarifas_left_bottom,删除不透明

我希望div是部分透明的,这样背景就可以看穿,但希望其他元素不像图像中那样透明。目前我使用的是
不透明度:.4

HTML

屏幕截图:


使用rgba颜色,而不是影响元素子元素的
不透明度

比如说

background-color: #AEABA1
opacity: .4
将转化为:

background-color: rgba(174, 171, 161, 0.4)

您可以为类
找到一个十六进制到RGBA的转换器。tarifas_left_top
。tarifas_left_bottom
,删除
不透明度
,改为使用
背景色:RGBA(#,#,#,#),#)
。对于不透明度为0.4的背景色
#AEABA1
,这将转换为
背景色:rgba(174171161,0.4)

对于IE8及以下版本,您需要使用
过滤器
属性覆盖背景

.tarifas_left_top {
    background-color: rgba(174,171,161,0.4);
    background: transparent\9;
    /* This '\9' is intentional. It's a CSS hack, but
       it works, and it resets the background in IE 8
       and below only. */
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#66AEABA1,endColorstr=#66AEABA1); 
    zoom: 1;
}

实际上,这样可以提供跨浏览器半透明背景,而不会影响元素子元素的不透明度。这些属性也可以用于
边框颜色
颜色
属性。

您可以制作一个JSFIDLE吗?另外,屏幕截图似乎没有显示…@misterManSam我希望div是透明的,这样背景就可以看得透,但希望其他元素()不要像图像中那样透明。-与下面的答案相同:)
background-color: rgba(174, 171, 161, 0.4)
.tarifas_left_top {
    background-color: rgba(174,171,161,0.4);
    background: transparent\9;
    /* This '\9' is intentional. It's a CSS hack, but
       it works, and it resets the background in IE 8
       and below only. */
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#66AEABA1,endColorstr=#66AEABA1); 
    zoom: 1;
}