opacity:0.5; background:transparent;

css 中的background:transparent

transparent是透明的意思,实际上background默认的颜色就是透明的属性
一般使用场景:
如果一个元素覆盖在另外一个元素之上,而你想显示下面的元素,这时你就需要把上面这个元素的background设置为transparent

CSS3 opacity 属性

设置 div 元素的不透明级别:(默认值:1)规定不透明度。从 0.0 (完全透明)到 1.0(完全不透明)。

div
{
opacity:0.5;
}

<!DOCTYPE html>
<html>
<head>
<style>
div
{
background-color:red;
opacity:1;
filter:Alpha(opacity=50); /* IE8 以及更早的浏览器 */
}
</style>
</head>
<body>

<div>本元素的不透明度是 0.5。请注意,文本和背景色都受到不透明级别的影响。</div>

</body>
</html>

 

posted on 2015-10-28 14:45  hi,勤奋小孩  阅读(310)  评论(0编辑  收藏  举报