1. 解决方法在需要滚动的元素下添加-webkit-overflow-scrolling: touch;
举个栗子(直接粘贴可用):
<!doctype html><html lang="en"><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>隐藏横向滚动条</title>
<style>
* {
margin: 0;
padding: 0;
}
.cover {
width: 100%;
overflow: hidden;
}
.father {
width: 100%;
padding: 0 10px;
background-color: #ff630c;
overflow-x: auto;
margin-top: -30px;
padding-bottom: 30px;
-webkit-transform: translatey(30px);
transform: translatey(30px);
box-sizing: border-box;
}
.son {
width: 500%;
padding-bottom: 10px;
}
.show {
width: 19%;
height: 60px;
background-color: #f00;
float: left;
margin-right: 5px;
text-align: center;
}
.second {
width: 100%;
height: 50px;
background-color: #eee;
z-index: 100000;
}
</style>
<style>
.father2 {
overflow-x: scroll;
width: 100%;
position: relative;
top: 10px;
margin-top: -10px;
-webkit-overflow-scrolling: touch;
}
.son2 {
width: 500%;
padding-bottom: 10px;
}
.show2 {
display: inline-block;
vertical-align: middle;
letter-spacing: -99999px;
text-align: center;
width: 19%;
margin-right: 10px;
height: 50px;
background-color: #f00;
}
</style></head><body>
<p class="cover">
<p class="father">
<p class="son">
<p class="show">1</p>
<p class="show">2</p>
<p class="show">3</p>
<p class="show">4</p>
<p class="show">5</p>
</p>
</p>
</p>
<p class="cover">
<p class="father2">
<p class="son2">
<p class="show2">1</p>
<p class="show2">2</p>
<p class="show2">3</p>
<p class="show2">4</p>
<p class="show2">5</p>
</p>
</p>
</p>
<p class="second"></p></body></html>
二、原因横向滚动慢,是因为safari原生支持-webkit-属性,但是默认使用的是浏览器中的渲染行为,所以滑动的时候回卡顿。但是使用这个overflow-scrolling属性以后,会创建一个原生的滚动选项卡,native-scrolling控件,因为滑动的程度会很流畅~~~~至于什么原因,可能就需要熟悉ios的同学探究一下原生控件咯.
兼容性: ios5.0 or later.
以上就是如何解决safari滚动慢,横向选项卡滚动缓慢的问题的详细内容。