【问题标题】:how can i set div opacity only not text? [duplicate]我怎样才能只设置 div 不透明度而不是文本? [复制]
【发布时间】:2014-02-20 20:51:25
【问题描述】:

我只想对 div 使用不透明度,而不是在文本上使用。我为 div 不透明度使用了一些代码,但它也显示了文本不透明度。我不想显示文本不透明度。我的代码在这里。

.opabenner {
width:569px;
height:100px;
float:left;
position:absolute;
background:#06F;
top:587px;
filter:alpha(opacity=60); /* IE */
   -moz-opacity:0.6; /* Mozilla */
   opacity: 0.6; /* CSS3 */
z-index:9999;
  }
 .tit {
position: absolute;
font-size: 20px;
color: #FFF;
text-align: center;
padding: 5px;
width: 580px;
  }


  <div class="opabenner"> 
         <h1 class="tit">Step inside love in 2014 and join today for FREE!</h1>
    </div>

【问题讨论】:

    标签: html css opacity


    【解决方案1】:

    为容器使用 RGBA 颜色

    p{
        color: red;
    }
    
    #transparent{
        background-color: rgba(0, 0, 0, .1); /* 0.1 alpha = 10% opacity */
    }
    

    预览:http://jsfiddle.net/EfDZC/

    【讨论】:

      【解决方案2】:

      使用background: rgba(0,0,0,.5); 删除opacity: 0.6;

      Sample Demo

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-22
      • 1970-01-01
      • 2020-10-29
      • 1970-01-01
      • 2021-06-07
      • 2016-03-07
      • 2012-06-08
      • 2017-09-02
      相关资源
      最近更新 更多