css - 使用后台附件 :fixed in safari on the ipad

标签 css ipad html

我希望重新创建类似于科普应用的效果。基本上有一个大的背景图片,然后在上面有 HTML/CSS 层。当用户滚动内容时,图像的背景位置应保持不变,而不是滚动。

显然在“常规”浏览器中我会使用 background-attachment:fixed,但这在 ipad 上似乎不起作用。我知道根据 safari 规范 position:fixed 不能像您预期的那样工作 - 但有什么方法可以实现这一点吗?

最佳答案

您可以使用此代码制作固定背景图层来解决此问题。

#background_wrap {
    z-index: -1;
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background-size: 100%;
    background-image: url('xx.jpg');
    background-attachment: fixed;
}

然后放<div id="background_wrap"></div>进入<body></body>

<body>
<div id="background_wrap"></div>
</body>

关于css - 使用后台附件 :fixed in safari on the ipad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3011226/

相关文章:

html - 滚动时内容重叠

ios - iPad presentModalViewController 出现在错误的位置

iphone - iOS:如何创建类似于新闻纸样式的UILabel

java - 在simpleCaptcha中更改图像样式

javascript - Div向下滚动并使用jquery向上滚动

javascript - 如何创建像苹果网站那样的滑动导航栏?

css - 如何在 Bootstrap v3.3.7 的 SCSS 版本中使用变量?

ios - 具有核心数据的主从应用程序

html - IE相当于-webkit-appearance?

html - 在 child 悬停时改变 parent 的CSS