在使用ScrollTo.js插件和Bootstrap时,我看到很多关于闪烁页面问题的帖子。特别是在iOS中。我尝试过很多建议都没有用。一旦用户滚动导航栏,我也会使用Bootstrap的Affix来粘贴导航栏。我不知道是不是导致闪烁的ScollTo或Affix,但.navbar似乎在iOS设备上跳跃或反弹。任何想法如何清除它?
<div class="navbar navbar-static-top" data-spy="affix" data-offset-top="66">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#top"><img src="images/logo@2x.png" width="209px" height="54px" class="logo"></a>
</div>
<div class="navbar-collapse collapse navbar-right">
<ul class="nav navbar-nav">
<li><a href="#about">About</a></li>
<li><a href="#news">News</a></li>
<li><a href="#portfolio">Portfolio</a></li>
<li><a href="#gallery">Gallery</a></li>
<li><a href="#blog">Blog</a></li>
</ul>
</div>
</div>
CSS
.navbar.affix {
position: fixed;
top: 0;
width: 100%;
}
JS
$(function() {
$('.navbar a').on('touchstart click', function(e) {
e.preventDefault();
target = this.hash;
$.scrollTo(target, 1000, {'axis': 'y'});
});