How to make address bar always visible on mobile browsers?
The other solutions on stackoverflow (such as this one) talk about preventing the body
from scrolling. You are setting the body height, which is good, but the body still has a scrollbar. Try:
- Setting the
body
overflow
to hidden. - Adding a new
div
that isheight: 100%
; andoverflow: auto
. Put the entire page inside this div. The div will have the scrollbar instead of the body. (Read the linked solution carefully).
Now, reasons I would discourage this:
- Users will hate you if you break the workflow they are used to. It is almost never the right thing to do.
- Scrolling the body is always much faster than a div scrolling. You will see very noticeable performance decreases if the page is very big at all.
Update: Address bar being moved
Chrome on Android is experimenting with moving the address bar down to the bottom of the screen to be more accessible for single-hand use. This is a great example of why a web page should never try to add hacks to work around browser behavior.
Javascript: always show Chrome address bar
You can create a div
, set the height to 100%
and use overflow-y:auto;
.
If you would copy this code and paste it into your project, you will see this is what you're looking for.
Please use this with caution, I personally love that chrome hides the navigation bar.
Example:
/* 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>
Related Topics
How to Get Display:Table-Cell Support in Ie? Any Pure JavaScript or Jquery Workaround
Apply Multiple Styles with .Style() Method in D3.Js
Ie Thumbnail Pixelation When High Resolution Image Is Set to Small Size
Using Media Queries to Only Include Js Files on Mobile
How to Dynamically Change CSS Style Attribute of Div Tag
D3: .Transition() Not Working with Events
Javascript: Hiding and Showing Div Tag with a Toggle Button
Set A:Visited Style with JavaScript or Jquery
Invert Filter Not Working on Ie and Safari
Why Does Queryselector('Div Span') Match Even Though Queryselector('Div') Does Not
Style a D3 Element with Jquery and CSS
How to Have Select Filter in Ngtable
Find Unused Images, CSS Rules, Js Script Blocks