如何在不影响文本的情况下设置背景不透明度 [英] How to set a background opacity without affecting the text
本文介绍了如何在不影响文本的情况下设置背景不透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我基本上是在尝试创建此代码:
I am basically trying to create this:
添加了带有背景图片的父容器,然后是子容器需要透明。
Added a parent container with a background image,then a child container that needs to be transparent.
这里是我的HTML:
<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:
.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;
}
此刻,按钮和文本也正在得到不透明。
如何在不影响文本和按钮的情况下具有透明背景?
At the moment,it's happening that the button and the texts are also getting the opacity. How can I have the transparent background without affecting the text and the button?
推荐答案
您可以使用 rgba
仅使背景颜色透明,例如:
You can use rgba
to make only the background color transparent, e.g.:
background: rgba(255, 249, 192, 0.7);
这篇关于如何在不影响文本的情况下设置背景不透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文