【问题标题】:Background image not showing on iOSiOS 上不显示背景图片
【发布时间】:2015-06-09 09:07:05
【问题描述】:

我有一个带有 JS 动态应用背景图像的 div。它在 iOS 中运行良好 - 无论是在 iOS Safari 和 iOS Chrome 中,背景图像都不会显示。很奇怪,我在网上没有找到任何答案。 以下是它的正常外观:

这里是它在 iOS(ipad 和 iphone)上的外观:

这里是 CSS,背景图像的值是由 JS 应用的:

.NavFrame {
  width: 104px;
  height: 58px;
  background-position: center center;
  background-size: cover;
  margin-right: 2%;
  background-image: url(http://www.test.com/test.jpg);
}

任何帮助将不胜感激。

更新:谢谢大家的回答,但最终这是我的 JS 代码中的一些错误。无论如何希望它可以帮助别人。

【问题讨论】:

标签: javascript ios css


【解决方案1】:

这样试试

.NavFrame {
      width: 104px;
      height: 58px;
      background-position: center center;

      margin-right: 2%;
      background-image: url(http://www.test.com/test.jpg);
      background-size: cover; 
    }

【讨论】:

    【解决方案2】:

    设置background-size 之后 background-image:

    .NavFrame {
      width: 104px;
      height: 58px;
      margin-right: 2%;
      background-image: url(http://www.test.com/test.jpg);
      background-position: center center;
      background-size: cover;
    }
    

    或简写:

    .NavFrame {    
      background: url(http://www.test.com/test.jpg) center center / cover;
    }
    

    【讨论】:

      【解决方案3】:

      stackoverflow pl 中已经讨论了这个问题。请参考以下链接 Background image not showing on iPad and iPhone

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-09-11
        相关资源
        最近更新 更多