Extend Ionic Grid with SASS

Extend Ionic Grid with SASS
Facebook
Twitter
LinkedIn

Interesting tips about IONIC

Ionic is an open source mobile app development framework, licensed under MIT, for developing native and progressive web apps with ease. It is actually a great way to bridge the gap between AngularJS web apps and hybrid mobile apps!

Ionic’s grid system is different than most, because of its use of the CSS Flexible Box Layout Module standard. The advantage is that the devices that Ionic supports, all support flexbox. There’s no restriction to a 12 column grid, or having to explicitly state how large each column should be.

Explicit Column Percentage Classnames
.col-1010%
.col-2020%
.col-2525%
.col-3333.3333%
.col-5050%
.col-6766.6666%
.col-7575%
.col-8080%
.col-9090%

But you cannot have one column to be 30% and the other 70% in a row. You have to use the above percentages. 

If you use Ionic with the SASS version (CSS with superpowers) you can extend the above classes with this code:

// Extend ionic sass grid

@for $i from 1 through 100 {

    .col-#{$i} {

        @include flex(0, 0, percentage($i)/100);

        max-width: percentage($i)/100;

    }

}

But you may need to extend the column offset too, with the following code:

// Extend ionic sass grid offset

@for $i from 1 through 100 {

    .col-offset-#{$i} {

        margin-left: percentage($i)/100;

    }

}

 

You may download the above code from here.


We would love to hear from you! If you have any feedback or run into issues using our framework, write your comment below.