/* ---------------------------------- */
/* ==Grids */
/* ---------------------------------- */
// WARNING : KNACSS grids are flexbox based and only supported by IE10+
// Tuto : http://www.alsacreations.com/tuto/lire/1659-une-grille-responsive-avec-flexbox-et-LESS.html
// Demo : http://codepen.io/raphaelgoetter/pen/ZYjwEB
// Usage in vanilla CSS:
// -
for an equal fourth columns grid container
// -
for an uneven columns grid container
// Usage with preprocessors : if you're using Sass, you can config grids variables :
// n = number of columns (default = 4) / g = gutter value (default = 1em)
// example : .grid-perso { @include grid(12, 10px); }
// ... or uneven grids :
// left = left ratio column (default = 2) / right = right ratio column (default = 1) / gutter (default = 1em)
// example : .grid-perso { @include uneven-grid(2, 1, 10px); }
[class*="grid-"] {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
margin-left: -$gutter;
}
[class*="grid-"] > * {
flex: 0 0 auto;
display: block; /* IE fix */
width: calc(100% * 1 / #{$number} - #{$gutter});
margin-left: $gutter;
}
// Sass mixins for *equal* columns grid container
// example : .grid-perso { @include grid(12); }
@mixin grid($number:$number,$gutter:$gutter) {
& > * {
width: calc(100% * 1 / #{$number} - #{$gutter});
}
& > .flex-item-double {
width: calc(100% * 2 / #{$number} - #{$gutter});
}
@media (min-width: ($tiny-screen + 1)) and (max-width: $small-screen) {
& > * {
width: calc(100% * 1 / 2 - #{$gutter});
}
& > .flex-item-double {
width: calc(100% - #{$gutter});
}
}
@media (max-width: $tiny-screen) {
& > * {
width: calc(100% - #{$gutter});
}
& > .flex-item-double {
width: calc(100% - #{$gutter});
}
}
}
// Examples : will be compiled in CSS
.grid-2 {
@include grid(2);
}
.grid-3 {
@include grid(3);
}
.grid-4 {
@include grid(4);
}
.grid-5 {
@include grid(5);
}
.grid-6 {
@include grid(6);
}
.grid-7 {
@include grid(7);
}
.grid-8 {
@include grid(8);
}
.grid-10 {
@include grid(10);
}
.grid-12 {
@include grid(12);
}
// LESS mixins for *unequal* columns grid container
// example : .grid-perso { @include uneven-grid(2, 1); }
@mixin uneven-grid($left:$left, $right:$right, $gutter:$gutter) {
& > *:nth-child(odd) {
$size: ($left / ($left + $right)) * 100%;
width: calc(#{$size} - #{$gutter});
}
& > *:nth-child(even) {
$size: ($right / ($left + $right)) * 100%;
width: calc(#{$size} - #{$gutter});
}
@media (max-width: $tiny-screen) {
& > *:nth-child(n) {
width: calc(100% - #{$gutter});
}
}
}
// Examples : will be compiled in CSS
.grid-2-1 {
@include uneven-grid(2,1);
}
.grid-1-2 {
@include uneven-grid(1,2);
}
.grid-3-1 {
@include uneven-grid(3,1);
}
.grid-1-3 {
@include uneven-grid(1,3);
}
.grid-3-2 {
@include uneven-grid(3,2);
}
.grid-2-3 {
@include uneven-grid(2,3);
}
.grid-4-1 {
@include uneven-grid(4,1);
}
.grid-1-4 {
@include uneven-grid(1,4);
}