尝试这样的事情:
background: rgba(200, 54, 54, 0.5);
前三个数字是背景颜色的红色、绿色和蓝色值,第四个是 Alpha 通道。
Alpha 通道的工作方式与不透明度值相同。
对于似乎不支持 rgba 的IE 8,您将需要一个 opacity 属性,这应该更适合跨浏览器:
.transparent {
/* works for IE 5+. */
filter:alpha(opacity=30);
/* works for IE 8. */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
/* works for old school versions of the Mozilla browsers like Netscape Navigator. */
-moz-opacity:0.3;
/* This is for old versions of Safari (1.x) with KHTML rendering engine */
-khtml-opacity: 0.3;
/* This is the "most important" one because it's the current standard in CSS. This will work in most versions of Firefox, Safari, and Opera. */
opacity: 0.3;
}