_grid-framework.scss 1.9 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. min-height: 1px; // Prevent columns from collapsing when empty
  11. padding-right: ($gutter / 2);
  12. padding-left: ($gutter / 2);
  13. }
  14. @each $breakpoint in map-keys($breakpoints) {
  15. $infix: breakpoint-infix($breakpoint, $breakpoints);
  16. // Allow columns to stretch full width below their breakpoints
  17. @for $i from 1 through $columns {
  18. .col#{$infix}-#{$i} {
  19. @extend %grid-column;
  20. }
  21. }
  22. .col#{$infix},
  23. .col#{$infix}-auto {
  24. @extend %grid-column;
  25. }
  26. @include media-breakpoint-up($breakpoint, $breakpoints) {
  27. // Provide basic `.col-{bp}` classes for equal-width flexbox columns
  28. .col#{$infix} {
  29. flex-basis: 0;
  30. flex-grow: 1;
  31. max-width: 100%;
  32. }
  33. .col#{$infix}-auto {
  34. flex: 0 0 auto;
  35. width: auto;
  36. max-width: none; // Reset earlier grid tiers
  37. }
  38. @for $i from 1 through $columns {
  39. .col#{$infix}-#{$i} {
  40. @include make-col($i, $columns);
  41. }
  42. }
  43. .order#{$infix}-first { order: -1; }
  44. .order#{$infix}-last { order: $columns + 1; }
  45. @for $i from 0 through $columns {
  46. .order#{$infix}-#{$i} { order: $i; }
  47. }
  48. // `$columns - 1` because offsetting by the width of an entire row isn't possible
  49. @for $i from 0 through ($columns - 1) {
  50. @if not ($infix == "" and $i == 0) { // Avoid emitting useless .offset-0
  51. .offset#{$infix}-#{$i} {
  52. @include make-col-offset($i, $columns);
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }