5 个回答

这就是opacity的特点,使元素透明,文字是元素的一部分,自然也透明了
答案我调整下,你用rgba:

background: rgba(0,0,0, 0.3)

opacity干掉

background: rgba(0,0,0,.5);

1 使用半透明背景色
2 使用伪元素

     .title-container{
            width: 100px;
            height: 50px;
            position: relative;
        }
        .title-container::before{
            content: '';
            width: 100%;
            height: 100%;
            display: block;
            /**
            background-color: rgba(0,0,0,.5);
            background-color: rgba(0,0,0,1);
            opacity: 0.5;
            **/
            position: absolute;
            left:0;
            right: 0;
            top:0;
            bottom:0;
        }
        
         <div class="title-container">
            <span>ABADE</span>
        </div>
新手上路,请多包涵

你不要给DIV OPACITY 用DIV 的背景rgba比如background:rgba(0,0,0,.3)来实现你要的效果

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题