html - 如何在不改变背景内容的情况下改变背景的不透明度?

标签 html css

我不知道如何使 background-image 不透明度为 0.5 并且内容完全不透明。

.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>

最佳答案

这是您追求的那种东西吗?

  .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>

关于html - 如何在不改变背景内容的情况下改变背景的不透明度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44414722/

相关文章:

html - "style"标签 : what's supposed to happen? 中的多个 "span"属性

html - 如何在 div 中垂直居中汉堡图标?

javascript - Jquery 自动完成功能在动态加载的部分 View 中不会被触发

javascript - 如何在 Django 表单中添加标签 ID

html - 具有任意列数且无需换行的网格容器

jquery - 将模态图像居中 : which <div> to style?

html - IE分页问题

javascript - 现代网络应用程序/网站如何进行回发? javascript/ajax、<form> 还是 X?

javascript - 同时有两个 Bootstrap 导航菜单

javascript - 自定义 Google Map API V3 PEGMAN 按钮