Skip to content

Instantly share code, notes, and snippets.

@helloncanella
Created December 6, 2016 04:13
Show Gist options
  • Save helloncanella/0cd7c0bc952c1d5b646642ed0cb92c5a to your computer and use it in GitHub Desktop.
Save helloncanella/0cd7c0bc952c1d5b646642ed0cb92c5a to your computer and use it in GitHub Desktop.
Fluid grid mixin
@mixin fluid-grid($cols:12, $gutter:1%, $grid-max-width:960px, $internal-lateral-padding:5%) {
.grid {
max-width: #{$grid-max-width};
margin: 0 auto;
padding: 0 #{$internal-lateral-padding};
&>* {
float: left;
}
@include clearFloat()
}
div[class^="col"] {
&:not(:last-child) {
margin-right: $gutter/2;
}
&:not(:first-child) {
margin-left: $gutter/2;
}
}
@for $i from 1 through $cols{
$ratio: $cols/$i;
.col-#{$i}-#{$cols}{
width: (100%-($ratio - 1)*$gutter)/$ratio
}
}
}
@mixin clearFloat() {
&::after {
display: block;
clear: both;
content: ''
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment