Skip to content

Instantly share code, notes, and snippets.

@matheuslc
Created January 17, 2014 18:13
Show Gist options
  • Save matheuslc/8478578 to your computer and use it in GitHub Desktop.
Save matheuslc/8478578 to your computer and use it in GitHub Desktop.
Zombie Grid done
// Name: Zombie Grid
// Author: Matheus Lucca do Carmo / me@matheuslc.com
// Version: 0.0.1
//--------------------------------------------
//
// Variables
//--------------------------------------------
$grid-columns: 12; // Set your columns
$grid-width: 100%;
// Clearfix
// by Nicholas Gallagher http://nicolasgallagher.com/micro-clearfix-hack/
//--------------------------------------------
%clearfix {
*zoom:1;
&:before,
&:after {
content:"";
display:table;
}
&:after {
clear:both;
}
}
//
// GRID
//--------------------------------------------
// Put that placeholder on body
%zombie-grid {
margin: 0;
@extend %clearfix;
}
// Mixin that generate all that magic
@mixin grid($media: false, $mediamin: 0px , $mediamax: 0px, $columns: $grid-columns, $width: $grid-width){
// Users want media querie?
@if( ($media != true)) {
// No!
@for $i from 0 to $columns {
// Thanks for Lucas Bebber for that help http://codepen.io/lbebber/
$j: $columns - $i;
%zombie-#{$j}{
float: left;
width: ($width / $columns) * $j;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
}
// All other styles
@content;
// User want media querie?
} @else {
// Yes!
@if (($media == true)) {
@media screen and (min-width: $mediamin) and (max-width: $mediamax){
@for $i from 0 to $columns {
// Thanks for Lucas Bebber for that help http://codepen.io/lbebber/
$j: $columns - $i;
%zombie-r-#{$j}{
float: left;
width: ($width / $columns) * $j;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
} // End for
@content; // All other styles
} // End Media Querie
} // End @else if
} // End @else
} // End Mixin
// Wrapper (for fixed grid)
%wrapper {
@extend %clearfix;
display: block;
width: $grid-width;
margin: 0 auto;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment