【问题标题】:How to make the background-image darker, without "Darking" other images in the same div? [duplicate]如何使背景图像更暗,而不会使同一 div 中的其他图像“变暗”? [复制]
【发布时间】:2019-09-13 20:48:55
【问题描述】:

我正在创建一个标题,其中背景图像是暗的,而标题上的其他图像是亮的。 如何使背景图像变暗而不使标题中的其他图像变暗?

【问题讨论】:

  • 基本上,你不能。背景图片不是元素,而是属性。
  • 使用伪::before 并给它一个z-index: 0; 并让其余的孩子包装z-index: 1; 可能会有一个技巧

标签: html css background-image


【解决方案1】:

这是我用了一段时间的方法。

body {
  position: relative;
  width: 100%;
  height: 100VH;
  background: url(http://fc02.deviantart.net/fs71/i/2011/274/6/f/ocean__sky__stars__and_you_by_muddymelly-d4bg1ub.png);
}

body::before {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .4);
  content: '';
}

【讨论】:

    【解决方案2】:

    正如@Paulie_D 所写,你真的不能。但我建议您只需复制和编辑原始图像文件(使其变暗)并将该版本用作背景图像。

    【讨论】:

      猜你喜欢
      • 2014-12-24
      • 2016-07-23
      • 2017-03-07
      • 2019-06-11
      • 2015-10-16
      • 1970-01-01
      • 2017-11-10
      • 1970-01-01
      • 2020-04-19
      相关资源
      最近更新 更多