【问题标题】:Media queries: background-image not displayed媒体查询:未显示背景图像
【发布时间】:2016-11-30 03:13:51
【问题描述】:

我正在尝试 here 在您通过移动设备(平板电脑和智能手机)访问网站时为每个页面添加不同的背景图片。

如您所见,我使用的是 WordpressfullPage.js

我在 CSS 中尝试过,但没有任何结果:

/* ----------- iPhone 4 and 4S ----------- */

@media only screen and (min-device-width: 320px) and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2) {
      #beste-lage { background-image: url(http://ap.nowcommu.myhostpoint.ch/wp-content/uploads/2016/07/text.png) !important; }
}

/* ----------- iPhone 5 and 5S ----------- */

/* Portrait and Landscape */
@media only screen and (min-device-width: 320px) and (max-device-width: 568px) and (-webkit-min-device-pixel-ratio: 2) {
      #beste-lage { background-image: url(http://ap.nowcommu.myhostpoint.ch/wp-content/uploads/2016/07/text.png) !important; }
}

/* ----------- iPhone 6 ----------- */

/* Portrait and Landscape */
@media only screen and (min-device-width: 375px) and (max-device-width: 667px) and (-webkit-min-device-pixel-ratio: 2) { 
      #beste-lage { background-image: url(http://ap.nowcommu.myhostpoint.ch/wp-content/uploads/2016/07/text.png) !important; }
}

/* ----------- iPhone 6+ ----------- */

/* Portrait and Landscape */
@media only screen and (min-device-width: 414px) and (max-device-width: 736px) and (-webkit-min-device-pixel-ratio: 3) { 
      #beste-lage { background-image: url(http://ap.nowcommu.myhostpoint.ch/wp-content/uploads/2016/07/text.png) !important; }
}

任何提示将不胜感激。

【问题讨论】:

  • 您确定媒体查询有效吗?尝试添加另一个属性以验证它是否在此选项中。

标签: css wordpress responsive-design media-queries


【解决方案1】:

结帐你没有关闭报价 - "

 #beste-lage { background-image: url("http://ap.nowcommu.myhostpoint.ch/wp-content/uploads/2016/07/text.png); }

应该是:

#beste-lage { background-image: url(http://ap.nowcommu.myhostpoint.ch/wp-content/uploads/2016/07/text.png) }

【讨论】:

  • 即使我改变它也不起作用。我是否将此应用于错误的 ID?
【解决方案2】:

将您的min-device-width 更改为min-width,应该可以解决问题。请参阅this 了解更多信息!

【讨论】:

  • 嗯,奇怪.. 通常我只使用@media screen and (min-width: 414px) and (max-width: 736px) {},没有像素比例和屏幕。
【解决方案3】:

背景不是#beste-lage,而是.bt-op-item-content

【讨论】:

  • 这就是问题所在。谢谢。
猜你喜欢
  • 2016-10-19
  • 1970-01-01
  • 2014-08-14
  • 2017-12-16
  • 2012-03-19
  • 1970-01-01
  • 2020-10-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多