_grid.scss 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /// Grid system
  2. //
  3. // Generate semantic grid columns with these mixins.
  4. @mixin make-container($gutter: $grid-gutter-width) {
  5. width: 100%;
  6. padding-right: $gutter / 2;
  7. padding-left: $gutter / 2;
  8. margin-right: auto;
  9. margin-left: auto;
  10. }
  11. @mixin make-row($gutter: $grid-gutter-width) {
  12. display: flex;
  13. flex-wrap: wrap;
  14. margin-right: -$gutter / 2;
  15. margin-left: -$gutter / 2;
  16. }
  17. // For each breakpoint, define the maximum width of the container in a media query
  18. @mixin make-container-max-widths($max-widths: $container-max-widths, $breakpoints: $grid-breakpoints) {
  19. @each $breakpoint, $container-max-width in $max-widths {
  20. @include media-breakpoint-up($breakpoint, $breakpoints) {
  21. max-width: $container-max-width;
  22. }
  23. }
  24. @include deprecate("The `make-container-max-widths` mixin", "v4.5.2", "v5");
  25. }
  26. @mixin make-col-ready($gutter: $grid-gutter-width) {
  27. position: relative;
  28. // Prevent columns from becoming too narrow when at smaller grid tiers by
  29. // always setting `width: 100%;`. This works because we use `flex` values
  30. // later on to override this initial width.
  31. width: 100%;
  32. padding-right: $gutter / 2;
  33. padding-left: $gutter / 2;
  34. }
  35. @mixin make-col($size, $columns: $grid-columns) {
  36. flex: 0 0 percentage($size / $columns);
  37. // Add a `max-width` to ensure content within each column does not blow out
  38. // the width of the column. Applies to IE10+ and Firefox. Chrome and Safari
  39. // do not appear to require this.
  40. max-width: percentage($size / $columns);
  41. }
  42. @mixin make-col-auto() {
  43. flex: 0 0 auto;
  44. width: auto;
  45. max-width: 100%; // Reset earlier grid tiers
  46. }
  47. @mixin make-col-offset($size, $columns: $grid-columns) {
  48. $num: $size / $columns;
  49. margin-left: if($num == 0, 0, percentage($num));
  50. }
  51. // Row columns
  52. //
  53. // Specify on a parent element(e.g., .row) to force immediate children into NN
  54. // numberof columns. Supports wrapping to new lines, but does not do a Masonry
  55. // style grid.
  56. @mixin row-cols($count) {
  57. > * {
  58. flex: 0 0 100% / $count;
  59. max-width: 100% / $count;
  60. }
  61. }