_grid-flex.scss 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. @media only screen and (max-width: $small-bp), (orientation: portrait) {
  8. flex-wrap:wrap;
  9. }
  10. }
  11. .row{
  12. @include row;
  13. }
  14. .row-rl{
  15. @include row;
  16. }
  17. // small
  18. .small-row {
  19. @media only screen and (max-width: $small-bp), (orientation: portrait) {
  20. @include row;
  21. }
  22. }
  23. // medium
  24. .med-row {
  25. @media only screen and (min-width: $small-bp+1) and (max-width: $med-bp) {
  26. @include row;
  27. }
  28. }
  29. // large
  30. .large-row {
  31. @media only screen and (min-width: $med-bp+1) {
  32. @include row;
  33. }
  34. }
  35. // %col-reset {
  36. // box-sizing: border-box;
  37. // }
  38. @mixin col($col, $offset: 0, $sum: $default_sum, $gap: $default_gap, $align: top) {
  39. // @extend %col-reset;
  40. box-sizing: border-box;
  41. padding-left: $gap*$offset;
  42. @if $col == $default_sum {
  43. // if last col, then no gap
  44. padding-right: 0;
  45. }@else{
  46. padding-right: $gap;
  47. }
  48. &:last-child{padding-right: 0;}
  49. // no offset with flex ??
  50. // margin-left: percentage(($col/$sum)*$offset);
  51. // col width
  52. flex-basis: percentage($col/$sum);
  53. }
  54. @for $c from 1 through $default_sum {
  55. .col-#{$c} {
  56. @include col($c);
  57. }
  58. // small
  59. .small-col-#{$c} {
  60. @media only screen and (max-width: $small-bp), (orientation: portrait) {
  61. @include col($c);
  62. }
  63. }
  64. // medium
  65. .med-col-#{$c} {
  66. @media only screen and (min-width: $small-bp+1) and (max-width: $med-bp) {
  67. @include col($c);
  68. }
  69. }
  70. // large
  71. .large-col-#{$c} {
  72. @media only screen and (min-width: $med-bp+1) {
  73. @include col($c);
  74. }
  75. }
  76. }
  77. @for $c from 1 through $default_sum - 1 {
  78. @for $o from 1 through $default_sum - $c {
  79. .col-#{$c}-offset-#{$o} {
  80. @include col($c, $o);
  81. }
  82. }
  83. }
  84. // TODO: replace with align-self:flex-start or flex-end
  85. // .col.float-right{
  86. // float: right;
  87. // padding-right: 0;
  88. // padding-left: $default_gap;
  89. // }