_grid-flex.scss 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // http://www.thesassway.com/intermediate/simple-grid-mixins
  2. @mixin row() {
  3. display:flex;
  4. flex-direction: row;
  5. flex-wrap: nowrap;
  6. align-items: stretch;
  7. // &:after{
  8. // content:"";
  9. // clear:both;
  10. // display: block;
  11. // }
  12. }
  13. .row{
  14. @include row;
  15. }
  16. .row-rl{
  17. @include row;
  18. }
  19. %col-reset {
  20. box-sizing: border-box;
  21. }
  22. @mixin col($col, $offset: 0, $sum: $default_sum, $gap: $default_gap, $align: top) {
  23. @extend %col-reset;
  24. padding-left: $gap*$offset;
  25. @if $col == $default_sum {
  26. // if last col, then no gap
  27. padding-right: 0;
  28. }@else{
  29. padding-right: $gap;
  30. }
  31. &:last-child{padding-right: 0;}
  32. // no offset with flex ??
  33. // margin-left: percentage(($col/$sum)*$offset);
  34. // col width
  35. flex-basis: percentage($col/$sum);
  36. }
  37. @for $c from 1 through $default_sum {
  38. .col-#{$c} {
  39. @include col($c);
  40. }
  41. // small
  42. .small-col-#{$c} {
  43. @media only screen and (max-width: $small-bp) {
  44. @include col($c);
  45. }
  46. }
  47. // medium
  48. .med-col-#{$c} {
  49. @media only screen and (min-width: $small-bp+1) and (max-width: $med-bp) {
  50. @include col($c);
  51. }
  52. }
  53. // large
  54. .large-col-#{$c} {
  55. @media only screen and (min-width: $med-bp+1) {
  56. @include col($c);
  57. }
  58. }
  59. }
  60. @for $c from 1 through $default_sum - 1 {
  61. @for $o from 1 through $default_sum - $c {
  62. .col-#{$c}-offset-#{$o} {
  63. @include col($c, $o);
  64. }
  65. }
  66. }
  67. // TODO: replace with align-self:flex-start or flex-end
  68. // .col.float-right{
  69. // float: right;
  70. // padding-right: 0;
  71. // padding-left: $default_gap;
  72. // }