2016-08-16 99 views
4

如何啓用「始終顯示」 Chrome中的地址欄在使用Javascript的移動設備上?
換句話說,當用戶向下滾動時不要隱藏。Javascript:始終顯示Chrome地址欄

+1

你可以假滾動,但它的棘手。 – gcampbell

+0

你可以用div來包裝你的HTML,將它的高度設置爲100% – 4dgaurav

+0

@thesaurabhway這將如何工作?正如我所看到的,你仍然會得到一個滾動頁面和一個隱藏地址欄 – Alexander

回答

1

您可以創建一個div,將高度設置爲100%並使用overflow-y:auto;

如果您要複製此代碼並將其粘貼到您的項目中,您會看到這是您要查找的內容。

請謹慎使用,我個人喜歡鉻隱藏導航欄。另外,爲了將來,請記住,如果您接受的答案並不能真正回答您的問題,那麼沒有人會放棄它。

例子:

/* You NEED to set the container height */ 
 
html, body { 
 
    height:100%; 
 
} 
 

 
/* Then override the scrollbar by a custom scrollable element: */ 
 
.customnavigation { 
 
    height:100%; 
 
    overflow-y:auto; 
 
}
<div class="customnavigation"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
    <img src="http://placehold.it/150x150"> 
 
</div>

+0

實際上它不。你能解釋這個理論嗎? – Alexander

+1

@Alexander我以前在頁面中使用過這樣的方法,但可能需要稍微調整它,方法是給它一個'margin-top'和較小的高度('calc(100% - margin-top)')。理論是這創造了一個有可滾動內容的盒子,但盒子本身只有頁面本身。因此,'body'不會滾動,也不會觸發標題被摺疊。 – Randy

+0

@亞歷山大您可能會發現這個有用的http://stackoverflow.com/questions/25298443/force-address-bar-to-show-in-mobile-chrome-app – Randy