Creating Fixed Headers and Footers

<div data-role="header" data-position="fixed">   <h1>Header</h1></div> ... <div data-role="footer" data-position="fixed">   <h4>Footer</h4></div>

By default, both the header and the footer flow with the content, meaning that if you scroll the content up or down, the header scrolls with the content. Often, you want the header, footer, or both to stay in a fixed position on the device screen so that it is always displayed. jQuery Mobile makes that adjustment simple to make.

To make the header or footer—or a toolbar for that matter—fixed, all you have to do is add the data-position="fixed" attribute to the <div>. This make them stay in place, the header at the top of the page and ...

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.