I noticed that even on iOS, Bootstrap's navbar
manages to stay at the top of the window with fixed
positioning. Despite the fact that I thought that this was meant to be impossible without re-implementing iOS scrolling?
I was wondering how this worked, and how I can do it for my own views? Nothing I've tried seems to work - the div gets misaligned while scrolling, and only jumps into position after scrolling ends.
EDIT: Here's a minimal(ish!) example. See how on iOS the fixedThing
jumps up as you scroll down. Perhaps it's something to do with interacting with the navbar
?
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
@import url('http://getbootstrap.com/dist/css/bootstrap.css');
.fixedThing {
position: fixed;
width: 100%;
height: 100%;
background: red;
opacity: 0.5;
}
.navbar {
width: 100%;
}
</style>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.1.0/bootstrap.min.js"></script>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
</div>
<div class="fixedThing"></div>
<p>...insert lots of page content so it scrolls ...</p>
</body>
</html>