我使用 1900X1200 图像作为我页面的背景:
body{
background: url(Layout/Ball7.png);
background-position: center center;
background-repeat:no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;}
它覆盖了桌面版和 iOs Safari 版的整个屏幕。
事情是,在 android native 浏览器上(我已经在三种不同的设备上尝试过)它在屏幕的顶部和底部留下了一个空白的白色区域(顶部和底部大约有 15% 的空白)。
如果我删除 background-position: center center;
,屏幕的顶部也会成为背景的一部分,但页面底部仍然会有空白(大约。 15%)。我也尝试使用此代码作为解决方案:
height:100% width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 0;
但是没有任何运气,屏幕的底部没有被覆盖。我在这里错过了什么吗?我尝试了很多选项,但没有一个完全符合我的需求。
可能的解决方案:我尝试使用非常大的图像 (1900x2500),它确实覆盖了整个屏幕,但这个解决方案是最后的手段,我想坚持使用 1900x1200 的图像。
感谢您对此事的任何了解。
最佳答案
body {
background: url(Layout/Ball7.png) no-repeat top left fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height:100%;
margin:0;
padding:0;
}
关于html - Android浏览器上的背景图片封面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22654629/