下面是设置背景封面的代码,我想设置背景封面的透明度,这样我就可以在上面显示一些文字。我得到了如下解决方案,但它对我不起作用。我不知道我想念它的地方。
style="background: url(images/football_ground.jpg) no-repeat center center fixed;-webkit-
background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;-moz-opacity:.30;
filter:alpha(opacity=30);
-khtml-opacity: 0.3; ">
最佳答案
目前,CSS 不允许更改背景图像的 alpha 值。如果你想解决这个问题,有几个不同的选择:
- 只需将您的背景图像保存为具有适当不透明度的透明 png。
- 使背景图像成为相对定位的父容器中自己的绝对定位元素。
.
<div class="parent">
<div class="background"></div>
<div class="foreground">some text</div>
</div>
关于html - 使用css设置背景覆盖的透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14537698/