#

Navigation Search

- Accordion
- AJAX Navigation
- Autocomplete
- Buttons
- Checkboxes
- Collapsibles
- Controlgroup
- Filterable New
- Dialogs
- Fixed toolbars
- Flip switch, slider
- Flip switch New
- Footer toolbar
- Form elements
- Grids
- Header toolbar
- Icons New
- Links
- Listviews
- Loader
- Navbar
- Navbar, persistent
- Pages
- Panels
- Popup
- Radio buttons
- Select
- Select, custom
- Slider, single
- Slider, dual range
- Table, column toggle
- Table, reflow
- Text inputs & textarea
- Transitions
- Collapsibles
- Dynamic collapsible
- Controlgroups
- Dynamic controlgroup
- Filterable
- Filterable inside custom select
- Listviews
- Grid Listview
- Autodividers Linkbar
- Autodividers Selector
- Maps
- Google Maps & Geolocation
- Google Maps with List toggle
- Navigation
- Backbone and Require.js example
- Redirection with server-side support
- Panels
- Panel styling
- Open panel on swipe
- Popups
- Dynamic popup
- Popup arrow size
- Popup alignment
- Responsive Tables
- Reflow: Custom styles
- Reflow: Heading groups
- Column toggle: Customization options
- Column toggle: Heading groups
- Column toggle demo: Phone comparison
- Sliders
- Tooltip extension
- Swipe
- Swipe to navigate
- Swipe to delete list item
- Forms
- Why won't my CSS styles apply correctly to a widget?
- Updating the value of enhanced form elements does not work.
- My HTML 5 inputs look different across devices and browsers.
- My range or search inputs are being change to number/text.
- Sometimes my custom select shows as a popup other times its a dialog.
- Disabling a button does not work.
- Controls in my fixed header or footer are not responding or behave erratically.
- Pages
- Why aren't my scripts and styles loading?
- Why isn't DOM ready working for my scripts?
- How do I load a page?
- Why is only the first page of my multi page document loaded?
- I'm trying to pass query params to a page but it's not working?
- I'm trying to pass information via the hash but it's not working?
- I'm trying to use the application cache but it's not working.
- Content injected into a page is not enhanced.
- Triggering create on injected HTML does not work.
- How can I stop JQM from auto-enhancing an element?
- How can I stop JQM from enhancing a block of elements?
- How do I control page titles?
- How do I load a page?
- How do I turn off the automatic hiding of the url bar?
- Events
- How do I use touch and mouse events?
- Theme and styling
- How does theming work?
- Apps
- How do I need to configure PhoneGap/Cordova?

# Grids API

The jQuery Mobile framework provides a simple way to build CSS-based columns that can also be responsive.

## Grid basics

Grids are 100% width, completely invisible (no borders or backgrounds) and don't have padding or margins, so they shouldn't interfere with the styles of elements placed inside them. Within the grid container, child elements are assigned `ui-block-a/b/c/d/e` in a sequential manner which makes each "block" element float side-by-side, forming the grid.

## Two column grids

To build a two-column (50/50%) layout, start with a container with a `class` of `ui-grid-a`, and add two child containers inside it classed with `ui-block-a` for the first column and `ui-block-b` for the second. On the blocks below, we're adding two classes: `ui-bar` to add the default bar padding and `ui-bar-a` to apply the background and font styling for the "a" toolbar theme swatch. For illustration purposes, an inline `style="height:60px"` attribute is also added to each grid to set each to a standard height.

Block A
Block B

Grid classes can be applied to any container. In this next example, we add `ui-grid-a` to a `fieldset`, and apply the `ui-block` classes to the container of each of the two buttons inside to stretch them each to 50% of the screen width:

## Three-column grids

The other grid layout configuration uses `class=ui-grid-b` on the parent, and 3 child container elements, each with its respective `ui-block-a/b/c` class, to create a three-column layout (33/33/33%).

Block A
Block B
Block C

And an example of a 3 column grid with buttons inside:

View more examples of buttons in grids.

## Four-column grids

A four-column, 25/25/25/25% grid is created by specifying `class=ui-grid-c` on the parent and adding a fourth block.

Block A
Block B
Block C
Block D

## Five-column grids

A five-column, 20/20/20/20/20% grid is created by specifying `class=ui-grid-d` on the parent and adding a fifth block.

Block A
Block B
Block C
Block D
Block E

## Multiple row grids

Grids are designed to wrap to multiple rows of items. For example, if you specify a 3-column grid (ui-grid-b) on a container that has nine child blocks, it will wrap to 3 rows of 3 items each. There is a CSS rule to clear the floats and start a new line when the `class=ui-block-a` is seen so make sure to assign block classes in a repeating sequence (a, b, c, a, b, c, etc.) that maps to the grid type:

Block A
Block B
Block C
Block A
Block B
Block C
Block A
Block B
Block C

## Grid solo class

The framework adds left and right margin to buttons in a grid (one exception: 100% width button elements). For a single button you can use a container with class `ui-grid-solo` and wrap the button in a div with class `ui-block-a` like the example below. This way the button will get the same margin. View more examples of buttons in grids.

Previous
Next

## Responsive grids

It's straightforward to take the standard grids and make them responsive by stacking the grid blocks at narrow widths. Since we just want to override the floats and widths of the standard grid styles below a single breakpoint, use a `max-width` breakpoint to only apply the stacked styling as an override.

We recommend adding a class (ex: `my-breakpoint`) to scope the styles for the media query so it can be applied selectively. From this basic start, you can customize the appearance further or even add additional breakpoints. See an example of a custom responsive grid.

    /* stack all grids below 40em (640px) */
    @media all and (max-width: 35em) {
    	.my-breakpoint .ui-block-a,
    	.my-breakpoint .ui-block-b,
    	.my-breakpoint .ui-block-c,
    	.my-breakpoint .ui-block-d,
    	.my-breakpoint .ui-block-e {
    		width: 100%;
    		float: none;
    	}
    }

## Breakpoint preset

To apply a preset breakpoint to stack grids below 35em (560px), add the `.ui-responsive` class to the grid container.

### Grid A (50/50)

Block A
Block B

### Grid B (33/33/33)

Block A
Block B
Block C

### Grid C (25/25/25/25)

A
B
C
D

### Grid D (20/20/20/20/20)

A
B
C
D
E