jQuery Mobile Grids
jQuery Mobile Grid Layout
jQuery Mobile provides a set of CSS-based column layouts. However, on mobile devices, due to the narrow screen width of phones, column layouts are generally not recommended.
But sometimes you want to arrange smaller elements (such as buttons or navigation tabs) side by side, like in a table. In that case, a column layout is recommended.
The columns in a grid are equal in width (totaling 100%), with no borders, backgrounds, margins, or padding.
There are four layout grids available:
| Grid Classes | column | Column widths | Corresponds to | Example |
|---|---|---|---|---|
| ui-grid-solo | 1 | 100% | ui-block-a | Try it |
| ui-grid-a | 2 | 50% / 50% | ui-block-a|b | Try it |
| ui-grid-b | 3 | 33% / 33% / 33% | ui-block-a|b|c | Try it |
| ui-grid-c | 4 | 25% / 25% / 25% / 25% | ui-block-a|b|c|d | Try it |
| ui-grid-d | 5 | 20% / 20% / 20% / 20% / 20% | ui-block-a|b|c|d|e | Try it |
|
| Inside a column container, child elements have the class ui-block-a|b|c|d|e depending on the number of columns. Columns float side by side.
**实例 1:**class 为 ui-grid-a(两列布局),您必须指定 ui-block-a 和 ui-block-b 的两个子元素。
**Example 2:** If the class is ui-grid-b (three-column layout), then three child elements ui-block-a, ui-block-b, and ui-block-c must be added. |
| --- | --- |
Custom grid
By using CSS, you can customize the column blocks:
Example
Try it »
You can also customize the blocks by using inline styles:
Text..
Multiple rows
You can also have multiple rows within a column.
**Note:** The ui-block-a class always creates a new row:
Example
Try it »
Responsive Grid
On small screens, it is not recommended to put too many buttons side by side in one row (the text will be shortened).
We use the ui-responsive class on the container to create a responsive grid: