有时我网站的背景 JPEG 无法完全加载。刷新不重新下载。我可以做什么来防止这种情况发生?
我在 Heroku 上托管该网站。图像加载到大约 2/3 时停止,并且背景颜色显示出来。这种情况在我身上已经发生过好几次了。刷新页面并不会使其消失。唯一的解决方案是清除我的缓存。我显然不希望我的用户这样做。有人以前见过这种情况和/或知道如何避免这种情况吗?我最近在 OS X Chrome 中看到过这个,不记得是否在其他浏览器中看到过。这是我的 CSS。
body {
background: #789cb5 url('/images/login_bg.jpg') center center fixed no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
I am hosting the site on Heroku. The image gets stops loading about 2/3 of the way down and the background color shows through. This has happened to me several times. Refreshing the page doesn't make it go away. The only solution is to clear my cache. I obviously wouldn't expect my users to do this. Has anyone seen this before and/or know how to avoid it? I've seen this in OS X Chrome most recently, can't remember if I've seen it in other browsers. Here's my CSS.
body {
background: #789cb5 url('/images/login_bg.jpg') center center fixed no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好使用 jQuery 来完成此操作。您每次都会获得稳定的结果,并且与
background-size
不同,它是跨浏览器兼容的。我们使用IMG
标签将其设为背景,它会自动调整大小以适应窗口大小。 。检查工作示例 http://jsfiddle.net/njC4d/2/
It's best to do this with jQuery. You'll get stable results everytime and it's Cross browser compatible unlike
background-size
. We use anIMG
tag to make it a background, it will automatically resize to fit window size. .Check working example at http://jsfiddle.net/njC4d/2/
能不能每次动态给图片URL添加一个参数>
Can you dynamically add a parameter to the image URL each time>