3

I don't know how to make background-image opacity 0.5 and the content full opacity.

.about-section {
  height: 100%;
  padding-top: 50px;
  text-align: center;
  /*background: #eee;*/
  background: url(../images/about.jpg);
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  opacity: 0.3;
}
<section id="about" class="about-section">
  <div class="container">
    <div class="row">
      <div class="col-lg-12">
        <h1 class="head">About Us</h1>

      </div>
    </div>
  </div>
</section>
Paolo Forgia
  • 6,572
  • 8
  • 46
  • 58
Y.EzzEldin
  • 801
  • 1
  • 8
  • 11
  • https://stackoverflow.com/questions/44398224/set-background-image-with-transparent-color-and-also-make-the-height-of-the-imag/44398374#44398374 – tech2017 Jun 07 '17 at 13:59
  • You can't with CSS, use a semi-transparent image – Paolo Forgia Jun 07 '17 at 14:04
  • The best solution would be to simply change your image to be more transparent. Other than that, you can try keeping the image as a seperate element. – gaynorvader Jun 07 '17 at 14:04
  • 1
    Possible duplicate of [CSS Background Opacity](https://stackoverflow.com/questions/10422949/css-background-opacity) – Hidden Hobbes Jun 07 '17 at 14:06

4 Answers4

5

Is this the sort of thing you're after?

  .about-section {
    height: 100%;
    padding-top: 50px;
    text-align: center;
  }
  
  .background {
    height: 100%;
    width: 100%;
    position: absolute;
    background: url(https://ichef-1.bbci.co.uk/news/976/media/images/83351000/jpg/_83351965_explorer273lincolnshirewoldssouthpicturebynicholassilkstone.jpg);
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    opacity: 0.3;
    
  }
<section id="about" class="about-section">
  <div class="background">
  </div>
  <div class="container">
    <div class="row">
      <div class="col-lg-12">
        <h1 class="head">About Us</h1>
      </div>
    </div>
  </div>
</section>
dennispreston
  • 596
  • 4
  • 14
2

You can use pseudo elements to get it just like following

.about-section {
  height: 100%;
  padding-top: 50px;
  text-align: center;
  /*background: #eee;*/
  background: url(http://lorempixel.com/400/200/);
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  position: relative;
}

.about-section::after {
  content: '';
  height: 100%;
  width: 100%;
  background: rgba(255, 255, 255, 0.5); /*Change as your need */
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}
<section id="about" class="about-section">
  <div class="container">
    <div class="row">
      <div class="col-lg-12">
        <h1 class="head">About Us</h1>

      </div>
    </div>
  </div>
</section>
LKG
  • 4,152
  • 1
  • 11
  • 21
1

You can use the ::before´-pseudo-element.

.about-section {
  position:relative; /* Notice this */
  height: 100%;
  padding-top: 50px;
  text-align: center;
}

.about-section::before {
  content:'';
  position:absolute;
  width:100%;
  height:100%;
  left:0px;
  top:0px;
  background: #000; /* change to whatever you want */
  opacity:0.3;
}
<section id="about" class="about-section">
  <div class="container">
    <div class="row">
      <div class="col-lg-12">
        <h1 class="head">About Us</h1>
      </div>
    </div>
  </div>
</section>
StuntHacks
  • 457
  • 3
  • 15
0

For the moment, CSS does not offer that possibility (unless your background is just a colour, in which case you can use rgba()).

To achieve this, you can place your .about-section in position: relative; and create a <div> inside it (preferably as the first child, or even better, as a ::before pseudo-element) absolutely positioned, with full width and height. You can then tweak its opacity as you wish without affecting the content.

chriskirknielsen
  • 2,839
  • 2
  • 14
  • 24