【问题标题】:responsive Hero-Image not working on iPhone响应式 Hero-Image 在 iPhone 上不起作用
【发布时间】:2018-12-01 18:14:21
【问题描述】:

我的网站存在以下问题:

我有一个带有背景图片的英雄部分。它覆盖了背景并使用background-attachmend: fixed。这很有效,在我的桌面上看起来很漂亮。

而在我的 iPhone 上,背景非常模糊,而且背景不是固定的。如果我将其更改为默认值background-attachmend: scroll,则背景会以良好的质量显示图片的右侧部分。

如果背景是固定的,iPhone 上的背景有时会完全变黑,这取决于我是否使用background-size: cover

我知道 iOS 不喜欢固定背景,但总得有办法解决这个问题吧?

希望你能帮助我!


编辑: 我的 <section> "home" 的 Css 代码

width: 100%;
height: 100%;
background-color: #151515;
background-image: url(../images/titelbild-skydance.jpg);
background-repeat: no-repeat;
background-position: bottom 100%;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
background-attachment: fixed;
min-height: 804px;
position: relative;

【问题讨论】:

  • 嗨。你能展示一下你到目前为止尝试过的代码吗?
  • 已编辑,谢谢!

标签: html css iphone web background-image


【解决方案1】:

对于响应式background-image,请为您的<section> 标签使用以下CSS

section {

min-height: 800px;
width: 100%;
background-image: url("../images/titelbild-skydance.jpg");
background-position: 0%, 0%, 50%, 50%;
background-attachment: scroll, fixed;
background-size: auto, cover;

}

【讨论】:

  • 那没有帮助,对不起。现在的背景不是固定的,不是在手机上不是在桌面上。一些元素的位置也发生了变化。
  • 您是否尝试过为此使用媒体查询?根据窗口大小更改图像?这样您就可以将两个图像(移动/桌面)固定在您想要的位置?
  • 我猜图像大小不是问题,它的大小会发生变化。在 Chrome DevTools 中查看 iPhone 显示了完美的行为。但是在网站上,iPhone 不使用 background-attachment:fixed,这会导致丑陋的模糊或图像丢失。
猜你喜欢
  • 1970-01-01
  • 2021-11-13
  • 2012-10-11
  • 1970-01-01
  • 1970-01-01
  • 2016-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多