Created
April 30, 2017 13:49
-
-
Save capynet/cc92c94815fc51c9da878fbdf2c85842 to your computer and use it in GitHub Desktop.
Genera una grilla basandose en flex.
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
/** | |
* Genera una grilla basandose en flex. | |
* | |
* $gutter: espacio entre cada elemento. (px, em, etc) | |
* $itemsByLine: Cantidad de items por defecto. (numero entero) | |
* $breakpoints: mapa de "breakpoint" -> items. | |
* | |
* Usage: | |
* @include flex-grid(9px, 2, (bp-s-m: 3, bp-m: 4, bp-m-l:6)); | |
* En este caso de uso por defecto de imprimen 2 items por fila con | |
* una separación de 9px entre ellos. A medida que aumentando | |
* el tamaño de pantalla la cantidad de items crece a 3, 4 y | |
* finalmente a 6 por fila. | |
*/ | |
@mixin flex-grid($gutter, $itemsByLine, $breakpoints: ()) { | |
display: flex; | |
flex-direction: row; | |
flex-wrap: wrap; | |
// El gutter añade espacio extra a los bordes del grid. | |
// Con un margen negativo lo contrarrestamos. | |
margin: -$gutter; | |
> * { | |
padding: $gutter; | |
width: 100% / $itemsByLine; | |
box-sizing: border-box; | |
@each $bp, $qty in $breakpoints { | |
// @todo sustituir por un mixing de breakpoints independiente del framework. | |
@include breakpoint(#{$bp}) { | |
width: 100% / $qty; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment