_grid-framework.scss 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Framework grid generation
  2. //
  3. // Used only by Bootstrap to generate the correct number of grid classes given
  4. // any value of `$grid-columns`.
  5. @mixin make-grid-columns($columns: $grid-columns, $gutter: $grid-gutter-width, $breakpoints: $grid-breakpoints) {
  6. // Common properties for all breakpoints
  7. %grid-column {
  8. position: relative;
  9. width: 100%;
  10. padding-right: $gutter / 2;
  11. padding-left: $gutter / 2;
  12. }
  13. @each $breakpoint in map-keys($breakpoints) {
  14. $infix: breakpoint-infix($breakpoint, $breakpoints);
  15. // Allow columns to stretch full width below their breakpoints
  16. @for $i from 1 through $columns {
  17. .col#{$infix}-#{$i} {
  18. @extend %grid-column;
  19. }
  20. }
  21. .col#{$infix},
  22. .col#{$infix}-auto {
  23. @extend %grid-column;
  24. }
  25. @include media-breakpoint-up($breakpoint, $breakpoints) {
  26. // Provide basic `.col-{bp}` classes for equal-width flexbox columns
  27. .col#{$infix} {
  28. flex-basis: 0;
  29. flex-grow: 1;
  30. max-width: 100%;
  31. }
  32. @for $i from 1 through $grid-row-columns {
  33. .row-cols#{$infix}-#{$i} {
  34. @include row-cols($i);
  35. }
  36. }
  37. .col#{$infix}-auto {
  38. @include make-col-auto();
  39. }
  40. @for $i from 1 through $columns {
  41. .col#{$infix}-#{$i} {
  42. @include make-col($i, $columns);
  43. }
  44. }
  45. .order#{$infix}-first { order: -1; }
  46. .order#{$infix}-last { order: $columns + 1; }
  47. @for $i from 0 through $columns {
  48. .order#{$infix}-#{$i} { order: $i; }
  49. }
  50. // `$columns - 1` because offsetting by the width of an entire row isn't possible
  51. @for $i from 0 through ($columns - 1) {
  52. @if not ($infix == "" and $i == 0) { // Avoid emitting useless .offset-0
  53. .offset#{$infix}-#{$i} {
  54. @include make-col-offset($i, $columns);
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }