ionic Grid
ionic's Grid differs from most other frameworks; it uses the Flexible Box Model. On mobile, basically all phones support it. The row style specifies a row, and the col style specifies a column.
Equal-Size Grid
In an element with the row style, if it contains col styles, the cols will be set to equal size.
In the following example, the row style contains 5 col styles, and each col is 20% wide.
.col
.col
.col
.col
.col
Specifying Column Width
You can set different sizes for the columns in a row. By default, columns are divided into equal sizes. But you can also set column widths by percentage (a row has 12 grids).
.col.col-50
.col
.col
.col.col-75
.col
.col
.col.col-75
.col
.col
Note: in the example, each col style automatically has a border and gray background added.
Some percentage-based style names for specifying column width are listed below:
| .col-10 | 10% |
|---|---|
| .col-20 | 20% |
| .col-25 | 25% |
| .col-33 | 33.3333% |
| .col-50 | 50% |
| .col-67 | 66.6666% |
| .col-75 | 75% |
| .col-80 | 80% |
| .col-90 | 90% |
Grid with Offsets
Columns can have a left offset; the example is as follows:
.col
.col
.col
.col
.col
Some percentage-based offset style names are as follows:
| .col-offset-10 | 10% |
|---|---|
| .col-offset-20 | 20% |
| .col-offset-25 | 25% |
| .col-offset-33 | 33.3333% |
| .col-offset-50 | 50% |
| .col-offset-67 | 66.6666% |
| .col-offset-75 | 75% |
| .col-offset-80 | 80% |
| .col-offset-90 | 90% |
Vertical Alignment Grid
The Flexible Box Model makes it easy to set vertical alignment of columns. Vertical alignment includes top, middle, and bottom, and can be applied to the columns of each row or to a specific column.
In the example, the last column is set with the tallest content to better demonstrate the vertical alignment grid.
.col
.col
.col
1
2
3
4
.col
.col
.col
1
2
3
4
.col
.col
.col
1
2
3
4
.col
.col
.col
1
2
3
4
.col
.col
.col
1
2
3
4
Responsive Grid
When a handheld device's screen switches, such as landscape or portrait, you need to set the grid of each row to adapt to different widths.
The responsive classes for different devices are as follows:
| Responsive Class | Description |
|---|---|
| .responsive-sm | Smaller than phone landscape |
| .responsive-md | Smaller than tablet portrait |
| .responsive-lg | Smaller than tablet landscape |
.col
.col
.col
.col