Created
December 6, 2016 04:13
-
-
Save helloncanella/0cd7c0bc952c1d5b646642ed0cb92c5a to your computer and use it in GitHub Desktop.
Fluid grid mixin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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