Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery Mobile Toolbars

jQuery Mobile Toolbars

Toolbar elements are usually located within the header and footer - making navigation easily accessible:


Header bar

The header bar generally contains the page title/logo or one or two buttons (usually home, options, or search).

You can add buttons to the left or right side of the header.

The following code adds a button to the left of the header title text and a button to the right of the header title text:

Example

  Home

 

Welcome to my homepage

  Search

Try it »

The following code adds a button to the left of the header title text:

Example

  Home

 

Welcome to my homepage

Try it »

However, if you place the button link after the

element, the text on the right will not be displayed. To add a button to the right of the header title, specify the class as "ui-btn-right":

Example

 

Welcome to my homepage

  Search

Try it »

lamp The header can contain one or two buttons, while the footer has no limit.

Footer bar

The footer bar is more flexible than the header bar - they are more functional and variable throughout the page, so it can contain as many buttons as needed:

Example

  Follow me on Facebook

  Follow me on Twitter

  Follow me on Instagram

Try it »

**Note:** The footer's style is different from the header (no padding or space, and buttons are not centered). We can use a simple style to solve this problem:

Example

Try it »

You can also group buttons in the footer horizontally or vertically:

Example

 

data-role="controlgroup" data-type="horizontal"

    Follow me on Facebook

    Follow me on Twitter

    Follow me on Instagram

 

Try it »


Positioning the header and footer bars

The header and footer can be positioned in three ways:

Use the data-position attribute to position the header and footer bars:

Inline positioning (default)

data-position="inline"

data-position="inline"

Try it »

Fixed positioning

data-position="fixed"

data-position="fixed"

Try it »

To enable fullscreen positioning, use data-position="fixed" and add the data-fullscreen attribute to the element:

Fullscreen positioning

data-fullscreen="true"

data-fullscreen="true"

Try it »

**Tip:** Fullscreen positioning is suitable for photos, images, and videos.

**Tip:** In fixed and fullscreen positioning, tapping the screen will hide and show the header and footer bars.


More examples

Displaying icons only on the toolbar
To display only icons on the toolbar, you can use the ui-btn-icon-notext class.