Merge pull request #185 from dsoriano/sass-grid-gutter
Improve grid and uneven-grid mixins
This commit is contained in:
commit
195de74f04
2 changed files with 44 additions and 18 deletions
|
@ -41,11 +41,18 @@
|
|||
letter-spacing: normal;
|
||||
}
|
||||
|
||||
// LESS mixin for custom grid container
|
||||
.check-new-margin(@newgutter, @multiplier) when not (@newgutter = @gutter) {
|
||||
margin-left: @newgutter * @multiplier;
|
||||
}
|
||||
|
||||
// LESS mixins for *equal* columns grid container
|
||||
// example : .grid-perso { .grid(12); }
|
||||
.grid(@number:@number, @gutter:@gutter) {
|
||||
.check-new-margin(@gutter, -1);
|
||||
& > * {
|
||||
width: ~'calc(100% * 1 / @{number} - @{gutter} - .01px)';
|
||||
.check-new-margin(@gutter, 1);
|
||||
}
|
||||
& > .@{kna-namespace}flex-item-double {
|
||||
width: ~'calc(100% * 2 / @{number} - @{gutter} - .01px)';
|
||||
|
@ -130,14 +137,19 @@
|
|||
// LESS mixins for *unequal* columns grid container
|
||||
// example : .grid-perso { .uneven-grid(2, 1); }
|
||||
.uneven-grid(@left:@left, @right:@right, @gutter:@gutter) {
|
||||
& > *:nth-child(odd) {
|
||||
.check-new-margin(@gutter, -1);
|
||||
& > * {
|
||||
.check-new-margin(@gutter, 1);
|
||||
&:nth-child(odd) {
|
||||
@size: (@left / (@left + @right)) * 100%;
|
||||
width: ~'calc(@{size} - @{gutter} - .01px)';
|
||||
}
|
||||
& > *:nth-child(even) {
|
||||
&:nth-child(even) {
|
||||
@size: (@right / (@left + @right)) * 100%;
|
||||
width: ~'calc(@{size} - @{gutter} - .01px)';
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: @small-screen) {
|
||||
& > *:nth-child(n) {
|
||||
width: ~'calc(100% - @{gutter} - .01px)';
|
||||
|
|
|
@ -43,12 +43,18 @@
|
|||
|
||||
// Sass mixins for *equal* columns grid container
|
||||
// example : .grid-perso { @include grid(12); }
|
||||
@mixin grid($number:$number,$gutter:$gutter) {
|
||||
@mixin grid($number:$number,$newgutter:$gutter) {
|
||||
@if $newgutter != $gutter {
|
||||
margin-left: -$newgutter;
|
||||
}
|
||||
& > * {
|
||||
width: calc(100% * 1 / #{$number} - #{$gutter} - .01px);
|
||||
width: calc(100% * 1 / #{$number} - #{$newgutter} - .01px);
|
||||
@if $newgutter != $gutter {
|
||||
margin-left: $newgutter;
|
||||
}
|
||||
}
|
||||
& > .#{$kna-namespace}flex-item-double {
|
||||
width: calc(100% * 2 / #{$number} - #{$gutter});
|
||||
width: calc(100% * 2 / #{$number} - #{$newgutter});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,18 +144,26 @@
|
|||
|
||||
// Sass 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});
|
||||
@mixin uneven-grid($left:$left, $right:$right, $newgutter:$gutter) {
|
||||
@if $newgutter != $gutter {
|
||||
margin-left: -$newgutter;
|
||||
}
|
||||
& > *:nth-child(even) {
|
||||
> * {
|
||||
@if $newgutter != $gutter {
|
||||
margin-left: $newgutter;
|
||||
}
|
||||
&:nth-child(odd) {
|
||||
$size: ($left / ($left + $right)) * 100%;
|
||||
width: calc(#{$size} - #{$newgutter});
|
||||
}
|
||||
&:nth-child(even) {
|
||||
$size: ($right / ($left + $right)) * 100%;
|
||||
width: calc(#{$size} - #{$gutter});
|
||||
width: calc(#{$size} - #{$newgutter});
|
||||
}
|
||||
}
|
||||
@media (max-width: $small-screen) {
|
||||
& > *:nth-child(n) {
|
||||
width: calc(100% - #{$gutter});
|
||||
width: calc(100% - #{$newgutter});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue