码迷,mamicode.com
首页 > 其他好文 > 详细

转载 | 如何实现模块半透明 文字内容不透明?

时间:2017-08-18 23:41:22      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:style   内容   方法   filter   pre   支持ie   半透明   box   lte   

两种方法

一种是用background:rgba(0, 0, 0, 0.5),兼容性只支持IE8往上另一种方法使用透明度

要考虑IE8往下可以用这个:

<style type="text/css">
.box{ 
    position:relative; 
    width:200px; 
    height:200px; 
    border:1px solid #666; 
    z-index:0;
}

.box .bg{ 
    background:red; 
    position:absolute; 
    z-index:-1; 
    opacity:0.5; 
    filter:alpha(opacity=50); 
    width:100%; 
    height:100%;
}
</style>

<div class="box">
    <!-- 背景 -->
    <div class="bg"></div>
    <!-- 内容 -->
    <div class="text">
        <p>呵呵,我不受透明度影响!</p>
    </div>
</div>

 

转载 | 如何实现模块半透明 文字内容不透明?

标签:style   内容   方法   filter   pre   支持ie   半透明   box   lte   

原文地址:http://www.cnblogs.com/One-sprite/p/7392459.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!