我们可以使用 background-blend-mode 属性来使 CSS 中的背景图像变暗。该属性设置背景的混合模式。此属性有多种选择。一些选项是 normal、multiply、darken、lighten, saturation 等。我们可以使用变暗选项使背景图像更暗。我们可以使用 rgba() 函数设置背景图像的颜色。
例如,在 CSS 中选择 background id 并使用 background 属性设置颜色和背景图像。将颜色设置为 rgba(0, 0, 0, 0.7) 并在 url() 函数中使用占位符图像。使用与第一种方法不同的背景属性来正确设置图像。接下来,使用 background-blend-mode 属性并将其设置为 darken。
通过这种方式,我们可以使用 background-blend-mode 属性使背景图像变暗。
示例代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum=1.0,minimum=1.0,user-scalable=0" />
<title>BFW NEW PAGE</title>
<style>
#oldbackground{
background: url('//repo.bfw.wiki/bfwrepo/image/5d65ea7d8bc8b.png');
height: 200px;
width: 300px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
#background{
background: rgba(0, 0, 0, 0.6) url('//repo.bfw.wiki/bfwrepo/image/5d65ea7d8bc8b.png');
height: 200px;
width: 300px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-blend-mode: darken;
}
</style>
</head>
<body>
<div id="oldbackground"></div>
<div id="background"></div>
</body>
</html>
网友回复
为啥所有的照片分辨率提升工具都会修改照片上的图案细节?
js如何在浏览器中将webm视频的声音分离为单独音频?
微信小程序如何播放第三方域名url的mp4视频?
ai多模态大模型能实时识别视频中的手语为文字吗?
如何远程调试别人的chrome浏览器获取调试信息?
为啥js打开新网页window.open设置窗口宽高无效?
浏览器中js的navigator.mediaDevices.getDisplayMedia屏幕录像无法录制SpeechSynthesisUtterance产生的说话声音?
js中mediaRecorder如何录制window.speechSynthesis声音音频并下载?
python如何直接获取抖音短视频的音频文件url?
js在浏览器中如何使用MediaStream与MediaRecorder实现声音音频多轨道混流?