Solving your issue with Susy
Susy allows overriding the number of columns. Many Susy mixins allow that — every mixin that accepts the $context
argument.
But the best way to override a context is with the at-breakpoint
mixin:
// Defining the breakpoints
$mobile-to-medium: 400px;
$medium-to-large: 800px;
// Defining columns
$columns-small: 1;
$columns-medium: 8;
$columns-large: 12;
// Starting with a one-column mobile grid
$total-columns: $columns-small;
// Global styles go here
// Mobile-only styles
@include at-breakpoint($total-columns $mobile-to-medium) {
// ...
}
// Medium-only styles go here
@include at-breakpoint($mobile-to-medium $columns-medium $medium-to-large) {
.item{
@include span-columns(3);
@include nth-omega(2n); } }
// Large-only styles go here
@include at-breakpoint($medium-to-large $columns-large) {
.item{
@include span-columns(4);
@include nth-omega(3n); } }
Omega supposes layered responsiveness: mobile styles are applied to all widths; medium styles are applied to medium and large widths, large styles are applied to large widths.
The approach above is not layered: mobile styles are applied only to mobile width, etc. This way you don't need to worry about omega applied where it's not supposed to go.
To use the Omega layered approach, just remove the third element (max-width) in at-breakpoint
calls. But then you have to apply @include remove-nth-omega()
:
// Defining the breakpoints
$mobile-to-medium: 400px;
$medium-to-large: 800px;
// Defining columns
$columns-small: 1;
$columns-medium: 8;
$columns-large: 12;
// Starting with a one-column mobile grid
$total-columns: $columns-small;
// Global styles go here
// Medium and large styles go here
@include at-breakpoint($mobile-to-medium $columns-medium) {
.item{
@include span-columns(3);
@include nth-omega(2n); } }
// Large-only styles go here
@include at-breakpoint($medium-to-large $columns-large) {
.item{
@include span-columns(4);
@include remove-nth-omega(2n);
@include nth-omega(3n); } }
An overview of an omega-less approach
There are SASS grid systems that don't use the "omega" parameter (not to be confused with the Omega theme for Drupal) that's necessary to be applied for the last item in each row. Instead, you provide each element's position (which column the item starts at) in addition to its column width.
To make that possible, another CSS positioning approach is used, known as "isolation". The first framework to use this approach was Zen Grids.
Susy also has support for this method with its isolate
and isolate-grid
mixins.
This overview would not be complete without mentioning Singularity, the latest and most advanced SASS grid framework. It supports both postioning methods and is extendable to support more in the future (like flexbox which has recently been added to Compass).