_grid.scss 1.6 KB

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