javascript - 视差滚动不适用于移动 css

标签 javascript jquery html css jquery-mobile

我的视差滚动不适用于移动设备,包括安卓和 iOS。该代码适用于桌面,但不适用于移动设备,无论是任何浏览器。背景图像不会以视差效果滚动。你可以在这里查看 https://dkpyk75z6sfdo.cloudfront.net/

这是 CSS 代码,

.home {
background: url(assets/images/img1.jpg) no-repeat center center fixed;
display: table;
height: 100%;
position: relative;
width: 100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#information {
background: url(assets/images/b1.jpeg) no-repeat center center fixed; 
display: table;
height: 100%;
z-index: -1;
position: relative;
width: 100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#information2 {
background: url(assets/images/ab9.jpeg) no-repeat center center fixed; 
display: table;
height: 100%;
z-index: -1;
position: relative;
width: 100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#information3 {
background: url(assets/images/c4.jpg) no-repeat center center fixed; 
display: table;
height: 100%;
z-index: -1;
position: relative;
width: 100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

HTML代码

<!-- first section - Home -->
<div class="home">
<div class="centered">
<h1>PARALLAX WEB DESIGN</h1>
</div>
</div>
<!-- /first section -->    

<!-- second section -->
<div id="information">
<div class="centered">
        <h1>SECTION 1</h1>
</div>
</div>
<!-- /second section -->

等等

最佳答案

Parallax 永远无法在移动设备上正常工作 - 这就是原因。

移动浏览器旨在尽可能高效地运行,以节省电池生命周期。他们这样做的一种方式是在滚动事件期间延迟 JS 执行。从症状上看,这将显示为视差不是视差,而是在滚动完成后跳到新位置。

我建议禁用所有视差到移动视口(viewport)。

关于此主题的进一步阅读:http://developer.telerik.com/featured/scroll-event-change-ios-8-big-deal/

关于javascript - 视差滚动不适用于移动 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44416732/

相关文章:

javascript - 通过单击 Oracle Apex 5 中的元素名称展开导航菜单

html - Typo3:将类添加到默认内容包装

asp.net - Visual Studio ASP.NET/HTML 重新格式化功能 - 它存在吗?

javascript - 更新属性 : 时 Android Studio 项目出错

javascript - Highcharts 手动设置 legendItemClick 事件

javascript - 如何在单击该 div 按钮时获取字段的输入值?

javascript - select2 在分页时与 ajax/jquery 中断

javascript - JS/jQuery 如何获取动态(响应式)div 的高度?

javascript - 输入文本字段验证检查

php - 将 php 下拉值传递到另一个 php 站点