_grid.scss 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // http://www.thesassway.com/intermediate/simple-grid-mixins
  2. $default_gap: 1em;
  3. $default_sum: 12;
  4. $small-bp:768px;
  5. $med-bp:1080px;
  6. $large-bp:1900px;
  7. @mixin row() {
  8. // font-size: 0;
  9. // white-space: nowrap;
  10. position: relative;
  11. // >*{
  12. // font-size: 16px;
  13. // }
  14. &:after{
  15. content:"";
  16. clear:both;
  17. display: block;
  18. }
  19. }
  20. %col-reset {
  21. width: 100%;
  22. // display: inline-block;
  23. // white-space:normal;
  24. // font-size: 16px;
  25. float:left;
  26. box-sizing: border-box;
  27. }
  28. @mixin col($col, $offset: 0, $sum: $default_sum, $gap: $default_gap, $align: top) {
  29. @extend %col-reset;
  30. padding-left: $gap*$offset;
  31. @if $col == $default_sum {
  32. padding-right: 0;
  33. }@else{
  34. padding-right: $gap;
  35. }
  36. &:last-child{padding-right: 0;}
  37. margin-left: percentage(($col/$sum)*$offset);
  38. // @media only screen and (min-width: 768px) {
  39. width: percentage($col/$sum);
  40. // vertical-align: $align;
  41. // }
  42. }
  43. .row{
  44. @include row;
  45. // html:not(.js) &{
  46. // overflow-y: auto;
  47. // }
  48. }
  49. @for $c from 1 through $default_sum {
  50. .col-#{$c} {
  51. @include col($c);
  52. }
  53. // small
  54. .small-col-#{$c} {
  55. @media only screen and (max-width: $small-bp) {
  56. @include col($c);
  57. }
  58. }
  59. // medium
  60. .med-col-#{$c} {
  61. @media only screen and (min-width: $small-bp+1) and (max-width: $med-bp) {
  62. @include col($c);
  63. }
  64. }
  65. // large
  66. .large-col-#{$c} {
  67. @media only screen and (min-width: $med-bp+1) {
  68. @include col($c);
  69. }
  70. }
  71. }
  72. @for $c from 1 through $default_sum - 1 {
  73. @for $o from 1 through $default_sum - $c {
  74. .col-#{$c}-offset-#{$o} {
  75. @include col($c, $o);
  76. }
  77. }
  78. }
  79. .col.float-right{
  80. float: right;
  81. padding-right: 0;
  82. padding-left: $default_gap;
  83. }