我正在尝试在背景中显示完整的图像。但!它表现出了非常奇怪的行为。
它只占我屏幕的60%。屏幕的其余部分呈白色。但是当我定义不透明度属性时,这种不透明度只适用于40%屏幕的其余部分,并且图像开始显示不透明效果(但仅在这40%屏幕中)。。。
我用谷歌搜索了很多次,也应用了很多css技巧,但它不能在不透明的情况下全屏显示。。。
请帮帮我!
css:
html, body {
height:100%;
}
body{
background: url(../..//images/background_pic.jpg) center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
opacity: 0.8;
}发布于 2016-07-29 03:49:54
我找到了这个方法来解决你的问题。检查this JSFiddle。
风格:
html, body {
}
.parent{
position:relative;
}
.background{
position:absolute;
background: url(http://farm6.static.flickr.com/5182/5613127636_e854aea66b_o.png) no-repeat center center fixed;
width: 100%;
height:100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
opacity: 0.3;
}
.foreground{
position:relative;
}HTML:
<div class="parent">
<div class="background"></div>
<div class="foreground">
Put text here.
</div>
</div>发布于 2016-07-28 04:02:45
将背景应用于html而不是正文。
html {
background: url(images/bg.jpg) no-repeat center center fixed;
background-size: cover;
}https://stackoverflow.com/questions/38622140
复制相似问题