【发布时间】:2015-11-17 09:25:33
【问题描述】:
我遇到了一个特殊的问题:我页面上 div 的背景图像在我的计算机的网络浏览器上运行良好,并且在 iOS 版 Safari 上正常运行,但适用于 iOS 的最新版 Chrome (v46) 可以不显示图片:
http://winstoncb.com/wp-content/themes/gridsby/test/test2.html
进一步观察:
- 在 Chrome iOS 上等待的时间再多也没用 - 它永远不会加载
- 如果我返回主屏幕然后再次进入 Chrome,图像仍然不显示
- 如果我返回主屏幕,打开另一个应用程序(LinkedIn、Safari 等),然后返回主屏幕,然后返回 Chrome……通常图像会显示!然而,它很挑剔——如果我把手机调到横向模式,图像就会再次消失。当我转回纵向时,它仍然消失了。
@media screen and (max-width: 500px) {
div#hero {
max-height: 400px;
background: url('http://winstoncb.com/wp-content/themes/gridsby/images/WCB-rectangle2-low-mobile.jpg') no-repeat;
}
}
@media screen and (max-width: 400px) {
div#hero {
background: url('http://winstoncb.com/wp-content/themes/gridsby/images/WCB-rectangle2-low-mobile.jpg') no-repeat;
background-position: 37% top;
max-height: 400px;
}
}
/* HERO IMAGE */
div#hero {
display: block;
width: 100%;
height: 500px;
margin-left: auto;
margin-right: auto;
max-width: 1500px;
background: url('http://winstoncb.com/wp-content/themes/gridsby/images/WCB-rectangle2-low.jpg') no-repeat;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-position: 37% top;
}
}
<div id="hero"></div>
这似乎是很多人都会遇到的问题,但我没有看到太多关于它的帖子。如果您能指出正确的方向,非常感谢。
温斯顿
【问题讨论】:
标签: ios css google-chrome background background-image