Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic 2 responsive grid

How can I make a responsive grid in Ionic 2? Ionic 1 supported reserved classes like responsive-md or responsive-sm that made grids responsive, but they don't seem to work in Ionic 2.

In my case I have an <ion-row> with three <ion-col>. I would like the columns to drop below each other when the display width drops below a threshold. Is it possible to do this with Ionic 2?

like image 891
vaer-k Avatar asked Mar 15 '16 17:03

vaer-k


People also ask

Is ionic grid system is responsive by default?

By default, the grid will take up 100% width. To set a maximum width based on the screen size add the fixed attribute.

How do you use the Ionic grid system?

Working with the Ionic Grid System is straightforward. There are two main classes – row for working with rows and col for columns. You can choose as many columns or rows you want. All of them will adjust its size to accommodate the available space, although you can change this behavior to suit your needs.


1 Answers

Update for Ionic 2, Ionic 3+:

Ionic now have an amazing grid system base on flexbox css. You can see in the docs.
To use it, just simple like that:

<ion-grid>
  <ion-row>
    <ion-col col-3></ion-col> //This col will take 3/12 = 25% width;
    <ion-col col-4></ion-col> //This col will take 4/12 = 33.33% width;
    <ion-col></ion-col>       //This col will take the rest of width;
  </ion-row>
</ion-grid>
like image 92
Duannx Avatar answered Nov 03 '22 19:11

Duannx