【问题标题】:My 'body' css background image is jumping in chrome我的“body”css 背景图像在 chrome 中跳跃
【发布时间】:2016-05-02 10:54:42
【问题描述】:

我正在开发一个 joomla 网站。我的身体标签有图像背景。当我在谷歌浏览器上重新加载页面或导航到另一个页面时,我的主 html 会首先加载,然后添加 body 标记的背景图像。因此,在每次重新加载时,您都会看到跳跃(或者更好地说就像 LED 亮起和熄灭)效果,因为首先您会看到带有默认背景颜色的 body 标签,然后添加背景图像。当然它发生得很快,但我想解决这个问题。 我知道在 Chrome 和 Mozilla Firefox 上加载 HTML 元素的顺序是不同的。那么如何在谷歌浏览器上解决这个问题呢?!

我的 CSS:

html {
    height: 100%;
    margin-bottom: 0.01em;
}    
html, body, div.MainWrapper {
    background:url('../images/common/bg.jpg') transparent repeat-x scroll center top;
}

【问题讨论】:

  • 甚至不是我的背景图片,而是我页面上其他html元素的所有背景图片都是在整个页面加载后加载的。也许我需要一个 jquery 来同步 chrome 中的所有加载!!!

标签: javascript jquery html css google-chrome


【解决方案1】:

仅适用于正文

body {
    background:url('../images/common/bg.jpg') transparent repeat-x scroll center top;
    background-attachment: fixed;
}

【讨论】:

  • 感谢您的回复;但这没有帮助。您建议我添加的行仅使我的页面在固定背景上滚动。我的问题是当我重新加载页面或导航到新页面时页面正在跳转。在某些页面中,不仅我的背景,而且我的其他 HTML 元素的背景图像都在跳跃。
猜你喜欢
  • 2012-11-09
  • 2012-03-05
  • 1970-01-01
  • 2012-09-22
  • 2021-07-08
  • 2020-01-22
  • 1970-01-01
  • 1970-01-01
  • 2016-07-24
相关资源
最近更新 更多