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?
Now Ionic is using Bootstrap grid system. We can also use fixed attribute on ion-grid to better utilize screen width.
I tried by using following code for my requirements. Please follow the comments for understanding.
We can override the breakpoints so I did this:
and here is the code using customised breakpoint:
You would get following output for low resolution devices i.e devices that are below min-width: 372px;
And following output for above devices:
Though it does not seem to appear in the Ionic 2 documentation currently, the
responsive-md
,responsive-sm
(etc.) classes in Ionic 1 now become individual attributes in Ionic 2.Here is an example:
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: