2016-08-17 1 views
2

J'essaie essentiellement de créer ceci: enter image description hereComment définir une opacité d'arrière-plan sans affecter le texte

Ajouté Un conteneur parent avec une image d'arrière-plan, puis un conteneur enfant qui doit être transparent.

Voici mon code 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> 

Et le 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; 
} 

En ce moment, il se passe que le bouton et les textes sont également obtenir l'opacité. Comment puis-je avoir l'arrière-plan transparent sans affecter le texte et le bouton?

+1

Utiliser 'RGBA()' 'couleur au lieu de # hex'. – Aziz

Répondre

5

Vous pouvez utiliser rgba pour faire que la couleur de fond transparent, .: par exemple

background: rgba(255, 249, 192, 0.7);