2017-08-05 55 views
0

我试图解决别人的问题, 但我仍然无法隐藏iPhone(Safari)中的地址栏。 这是我的代码。JQuery移动时隐藏地址栏滚动

HTML:

<div class="Nav col-xs-12"> 
</div> 
<div class="ScrollBack"> 
    <div class="Banner col-xs-12"> 
    </div> 
    <div class="Content col-xs-12"> 
    </div>  
</div> 

CSS:

.ScrollBack{ 
    width: 100vw; 
    height: 110vh; 
    overflow-y:scroll; 
} 
.Nav{ 
    background: white; 
    height: 6.8vh; 
} 
.Banner{ 
    background: green; 
    height: 39.4vh; 
} 
.Content{ 
    background: blue; 
    height: 53.8vh; 
} 

的Javascript:

<script> 
    window.addEventListener("load", function() {    
     window.scrollTo(0, 1); 
    }); 
</script> 

我需要始终在顶部显示DIV(类= '导航'), 或者是我无法触发scoll事件的问题?

+0

我还在这里找到了一个有趣的文章,提供了一个可能的解决方案:http://menacingcloud.com/?c=iPhoneAddressBar – lumio

回答

-1
$(function(){$(window).bind('scroll', function() {}); }); 

像这样绑定滚动事件。