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

jQuery Mobile Panels

jQuery Mobile Panels

Panels in jQuery Mobile slide out from the left side of the screen to the right.

Create a panel by adding the data-role="panel" attribute to a

element with a specified id.

in

Add HTML markup to display your panel content:



面板标题..

文本内容..

Note: The panel markup must be placed before or after the page composed of header, content, and footer.

To access the panel, create a link pointing to the panel's

id; clicking the link will open the panel:



打开面板

A simple panel example

Example

 

data-role="panel" id="myPanel"

   

Panel header..

   

Panel content..

 

 

   

Standard page header

 

 

   

Click the button below to open the panel.

   

href="#myPanel"

class="ui-btn ui-btn-inline">Open panel

 

 

   

Footer text

 

Try it »


Close panel

You can close the panel by clicking outside the panel area, pressing the Esc key, or swiping. You can disable closing the panel by swiping and clicking by using data-* attributes:

property Value Description Example
data-dismissible true | false Specifies whether the panel can be closed by clicking outside the panel area. Try it
data-swipe-close true | false Specifies whether it can be closed by swiping. Try it

You can use a button to close the panel: just add the data-rel="close" attribute in the panel's

. For performance reasons, we need the close link's href attribute to point to the page's ID.

Example

 

Panel header..

 

Some text content in the panel..

 

href="#pageone" data-rel="close"

class="ui-btn ui-btn-inline">Close panel

Try it »


Panel display

You can control how the panel is displayed using the data-display attribute:

Attribute values Description
data-display="overlay" Display the panel over the content
data-display="push" It "pushes" the panel and the page at the same time.
data-display="reveal" The default value, which slides the page out like a slide show to reveal the panel

Example

data-display="overlay"

data-display="reveal"

data-display="push"

Try it »


Panel positioning

By default, the panel appears on the left side of the screen. To have the panel appear on the right side of the screen, specify the data-position="right" attribute.

Example

data-position="right"

Try it »

You can specify that the panel's content scrolls with the page. By default, the panel scrolls together with the page (but the panel's content still stays at the top of the page). If you need the panel content to be fixed and not scroll with the page, add the data-position-fixed="true" attribute to the panel:

Example

data-position-fixed="true"

Try it »