_grid-framework.scss 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. .col#{$infix}-auto {
  33. flex: 0 0 auto;
  34. width: auto;
  35. max-width: 100%; // Reset earlier grid tiers
  36. }
  37. @for $i from 1 through $columns {
  38. .col#{$infix}-#{$i} {
  39. @include make-col($i, $columns);
  40. }
  41. }
  42. .order#{$infix}-first { order: -1; }
  43. .order#{$infix}-last { order: $columns + 1; }
  44. @for $i from 0 through $columns {
  45. .order#{$infix}-#{$i} { order: $i; }
  46. }
  47. // `$columns - 1` because offsetting by the width of an entire row isn't possible
  48. @for $i from 0 through ($columns - 1) {
  49. @if not ($infix == "" and $i == 0) { // Avoid emitting useless .offset-0
  50. .offset#{$infix}-#{$i} {
  51. @include make-col-offset($i, $columns);
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }