refonte du systeme de grilles Flexbox

This commit is contained in:
raphaelgoettter 2015-03-30 12:24:54 +02:00
parent a5c52dca13
commit 2b3e0f0f9c
2 changed files with 37 additions and 60 deletions

View file

@ -21,48 +21,40 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-between;
margin-left: -@gutter; margin-left: -@gutter;
} }
[class*="grid-"] > * { [class*="grid-"] > * {
flex: 0 0 auto; flex: 0 0 auto;
display: block; /* IE fix */ display: block; /* IE fix */
border-left: @gutter solid transparent; width: ~'calc(100% * 1 / @{number} - @{gutter})';
background-clip: padding-box !important; /* no background on border */ margin-left: @gutter;
} }
// LESS mixins for *equal* columns grid container // LESS mixins for *equal* columns grid container
// example : .grid-perso { .grid(12); } // example : .grid-perso { .grid(12); }
.grid(@number:@number) { .grid(@number:@number, @gutter:@gutter) {
& > * { & > * {
width: (1/@number * 100) + 0%; width: ~'calc(100% * 1 / @{number} - @{gutter})';
} }
& > .flexitem-double { & > .flexitem-double {
width: (2/@number * 100) + 0%; width: ~'calc(100% * 2 / @{number} - @{gutter})';
}
@media (min-width: (@small-screen + 1)) and (max-width: @medium-screen) {
& > * {
width: 33.3333%;
}
& > .flexitem-double {
width: 66.6666%;
}
} }
@media (min-width: (@tiny-screen + 1)) and (max-width: @small-screen) { @media (min-width: (@tiny-screen + 1)) and (max-width: @small-screen) {
& > * { & > * {
width: 50%; width: ~'calc(100% * 1 / 2 - @{gutter})';
} }
& > .flexitem-double { & > .flexitem-double {
width: 100%; width: ~'calc(100% - @{gutter})';
} }
} }
@media (max-width: @tiny-screen) { @media (max-width: @tiny-screen) {
& > * { & > * {
width: 100%; width: ~'calc(100% - @{gutter})';
} }
& > .flexitem-double { & > .flexitem-double {
width: 100%; width: ~'calc(100% - @{gutter})';
} }
} }
} }
@ -107,20 +99,18 @@
// LESS mixins for *unequal* columns grid container // LESS mixins for *unequal* columns grid container
// example : .grid-perso { .uneven-grid(2, 1); } // example : .grid-perso { .uneven-grid(2, 1); }
.uneven-grid(@left:@left, @right:@right, @gutter:@gutter) {
.uneven-grid(@left:@left, @right:@right) {
& > *:nth-child(odd) { & > *:nth-child(odd) {
width: (@left / (@left + @right)) * 100%; @size: (@left / (@left + @right)) * 100%;
width: ~'calc(@{size} - @{gutter})';
} }
& > *:nth-child(even) { & > *:nth-child(even) {
width: (@right / (@left + @right)) * 100%; @size: (@right / (@left + @right)) * 100%;
width: ~'calc(@{size} - @{gutter})';
} }
@media (max-width: @tiny-screen) { @media (max-width: @tiny-screen) {
& > *:nth-child(n) { & > *:nth-child(n) {
width: 100%; width: ~'calc(100% - @{gutter})';
} }
} }
} }

View file

@ -21,51 +21,40 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-between;
margin-left: -$gutter; margin-left: -$gutter;
} }
[class*="grid-"] > * { [class*="grid-"] > * {
flex: 0 0 auto; flex: 0 0 auto;
display: block; /* IE fix */ display: block; /* IE fix */
border-left: $gutter solid transparent; width: calc(100% * 1 / #{$number} - #{$gutter});
background-clip: padding-box !important; /* no background on border */ margin-left: $gutter;
} }
// Sass mixins for *equal* columns grid container // Sass mixins for *equal* columns grid container
// example : .grid-perso { @include grid(12); } // example : .grid-perso { @include grid(12); }
@mixin grid($number:$number) { @mixin grid($number:$number,$gutter:$gutter) {
& > * { & > * {
width: (1/$number * 100) + 0%; width: calc(100% * 1 / #{$number} - #{$gutter});
} }
& > .flexitem-double { & > .flexitem-double {
width: (2/$number * 100) + 0%; width: calc(100% * 2 / #{$number} - #{$gutter});
} }
@media (min-width: ($small-screen + 1)) and (max-width: $medium-screen) {
& > * {
width: 33.3333%;
}
& > .flexitem-double {
width: 66.6666%;
}
}
@media (min-width: ($tiny-screen + 1)) and (max-width: $small-screen) { @media (min-width: ($tiny-screen + 1)) and (max-width: $small-screen) {
& > * { & > * {
width: 50%; width: calc(100% * 1 / 2 - #{$gutter});
} }
& > .flexitem-double { & > .flexitem-double {
width: 100%; width: calc(100% - #{$gutter});
} }
} }
@media (max-width: $tiny-screen) { @media (max-width: $tiny-screen) {
& > * { & > * {
width: 100%; width: calc(100% - #{$gutter});
} }
& > .flexitem-double { & > .flexitem-double {
width: 100%; width: calc(100% - #{$gutter});
} }
} }
} }
@ -110,20 +99,18 @@
// LESS mixins for *unequal* columns grid container // LESS mixins for *unequal* columns grid container
// example : .grid-perso { @include uneven-grid(2, 1); } // example : .grid-perso { @include uneven-grid(2, 1); }
@mixin uneven-grid($left:$left, $right:$right, $gutter:$gutter) {
@mixin uneven-grid($left:$left, $right:$right) {
& > *:nth-child(odd) { & > *:nth-child(odd) {
width: ($left / ($left + $right)) * 100%; $size: ($left / ($left + $right)) * 100%;
width: calc(#{$size} - #{$gutter});
} }
& > *:nth-child(even) { & > *:nth-child(even) {
width: ($right / ($left + $right)) * 100%; $size: ($right / ($left + $right)) * 100%;
width: calc(#{$size} - #{$gutter});
} }
@media (max-width: $tiny-screen) { @media (max-width: $tiny-screen) {
& > *:nth-child(n) { & > *:nth-child(n) {
width: 100%; width: calc(100% - #{$gutter});
} }
} }
} }