首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在不影响文本的情况下设置背景不透明度

如何在不影响文本的情况下设置背景不透明度
EN

Stack Overflow用户
提问于 2016-08-17 18:53:51
回答 1查看 29.9K关注 0票数 8

我基本上是在尝试创建以下内容:

添加一个带有背景图像的父容器,然后添加一个需要透明的子容器。

下面是我的HTML:

代码语言:javascript
复制
<div class="scent-brand-contact">
    <div class="scent-brand-container">               
       <section id="black-studio-tinymce-8" class="widget-1 widget-first widget-odd widget widget_black_studio_tinymce">
            <div class="textwidget">
                <p>All our fragrances are developed in compliance with the International Fragrance Association ensuring strict adherence to safety purity and manufacturing standards.</p>
                <p>LEARN MORE ABOUT HOW SCENT BRANDING CAN BENEFIT YOUR BUSINESS</p>
            </div>
        </section>
        <section id="text-4" class="widget-2 widget-last widget-even widget widget_text">
            <div class="textwidget">
            <button type="button">contact us today</button>
            </div>
        </section>                    
   </div>
</div>

和CSS:

代码语言:javascript
复制
.scent-brand-contact{
    position:relative;
    background-image: url(images/lemon.jpg);
    background-position: center center;
    background-attachment: fixed;
    background-size: cover;
    min-height:380px;
}
.scent-brand-container {
    background-color: #fff9c0;
    padding: 10px;
    opacity: 0.7;
    padding-top: 5%;
    margin: auto;
    position: absolute;
    top: 12%;
    width: 100%;
    min-height: 285px;
}

目前,按钮和文本也变得不透明。怎样才能在不影响文本和按钮的情况下获得透明的背景?

EN

回答 1

Stack Overflow用户

发布于 2016-08-17 18:55:50

您可以使用rgba仅使背景颜色透明,例如:

代码语言:javascript
复制
background: rgba(255, 249, 192, 0.7); 
票数 20
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38994637

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档