【发布时间】:2016-04-12 15:40:14
【问题描述】:
我遇到了一个问题,我有一个背景图像我想将不透明度设置为 0.35,我看到通过使用图像作为标签,使用绝对属性可以欺骗 CSS 没有背景图像不透明度选择器。我还在其他图像上设置了最大宽度,所以当我尝试这样做时,我的所有图像都恢复到原来的巨大尺寸。这是我的代码,任何答案都会有所帮助,我恢复到具有最大宽度图像的原始代码。
html {
background-image: url(*image url*);
background-repeat: no-repeat;
background-size: cover;
}
img {
max-width: 100px;
max-height: 100px;
}
.navBar {
color: white;
text-align: right;
}
【问题讨论】:
-
背景图片不在 html 标签上。将其更改为 body 标签。另外,不知道为什么要更改背后没有任何东西的图像的不透明度?
-
当然背景图片可以放在 html 标签上 - 将它移到 body 上没有区别。
-
这是一张深色图片,我要选择深色主题
标签: html css image background-image opacity