【问题标题】:background-size fixed not working in mobile chrome背景大小固定在移动 chrome 中不起作用
【发布时间】:2019-12-02 03:49:25
【问题描述】:

在我的网站here 中,我使用了背景图片作为<body style="background: url(http://www.monsoonmalabar.com/assets/jum1.jpg) no-repeat center center fixed;"> 的正文 它没有显示在移动 chrome 浏览器中。我试过下面的代码,

-webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  height: 100%;
  min-height: 100%;
  z-index: -1;
  -webkit-transform: translateZ(0);
}

仍然没有在移动版 chrome 中显示。有什么解决方法吗?

【问题讨论】:

  • 请在此处发布您的 HTML 和 CSS。一旦你修复了你的网站,这个问题对未来的访问者将毫无用处。请阅读:How to create a Minimal, Complete, and Verifiable example
  • 我的问题中有 html 和 css
  • HTML 在哪里?我只看到 CSS 的一个非常小的 sn-p。这没有帮助。

标签: css google-chrome responsive-design background-image


【解决方案1】:

由于您使用了background 限定符,它会覆盖所有预设样式(除非使用!important)。

您可以改为在 .bod 类中设置背景的所有属性,然后像下面那样设置 background-image 内联,如果它应该一直是相同的图像,您也可以添加内联。

.bod {
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    background-repeat: no-repeat;
    height: 100%;
    min-height: 100%;
    z-index: -1;
    -webkit-transform: translateZ(0);
}

在你的身体标签内:

background-image: url([path to your image]);

【讨论】:

  • 现在移动 chrome 显示一个奇怪的图像,有时它在刷新浏览器时略有变化。没有给出正确的图像,但有时它给出了正确的图像
  • 你能否提供更多细节,比如奇怪的图像是什么?屏幕截图可能会有所帮助。
  • here 是一,刷新后我得到了this
  • 我无法登录移动版 chrome。但我可以登录,图像在 android firefox 中显示完美。我可以在移动版 chrome 中看到它吗?
猜你喜欢
  • 1970-01-01
  • 2013-10-02
  • 1970-01-01
  • 2019-07-12
  • 1970-01-01
  • 2013-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多