123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- // html-grid.scss v1.0 | @ajlkn | MIT licensed */
-
- // Mixins.
-
- /// Initializes the current element as an HTML grid.
- /// @param {mixed} $gutters Gutters (either a single number to set both column/row gutters, or a list to set them individually).
- /// @param {mixed} $suffix Column class suffix (optional; either a single suffix or a list).
- @mixin html-grid($gutters: 1.5em, $suffix: '') {
-
- // Initialize.
- $cols: 12;
- $multipliers: 0, 0.25, 0.5, 1, 1.50, 2.00;
- $unit: 100% / $cols;
-
- // Suffixes.
- $suffixes: null;
-
- @if (type-of($suffix) == 'list') {
- $suffixes: $suffix;
- }
- @else {
- $suffixes: ($suffix);
- }
-
- // Gutters.
- $guttersCols: null;
- $guttersRows: null;
-
- @if (type-of($gutters) == 'list') {
-
- $guttersCols: nth($gutters, 1);
- $guttersRows: nth($gutters, 2);
-
- }
- @else {
-
- $guttersCols: $gutters;
- $guttersRows: 0;
-
- }
-
- // Row.
- display: flex;
- flex-wrap: wrap;
- box-sizing: border-box;
- align-items: stretch;
-
- // Columns.
- > * {
- box-sizing: border-box;
- }
-
- // Gutters.
- &.gtr-uniform {
- > * {
- > :last-child {
- margin-bottom: 0;
- }
- }
- }
-
- // Alignment.
- &.aln-left {
- justify-content: flex-start;
- }
-
- &.aln-center {
- justify-content: center;
- }
-
- &.aln-right {
- justify-content: flex-end;
- }
-
- &.aln-top {
- align-items: flex-start;
- }
-
- &.aln-middle {
- align-items: center;
- }
-
- &.aln-bottom {
- align-items: flex-end;
- }
-
- // Step through suffixes.
- @each $suffix in $suffixes {
-
- // Suffix.
- @if ($suffix != '') {
- $suffix: '-' + $suffix;
- }
- @else {
- $suffix: '';
- }
-
- // Row.
-
- // Important.
- > .imp#{$suffix} {
- order: -1;
- }
-
- // Columns, offsets.
- @for $i from 1 through $cols {
- > .col-#{$i}#{$suffix} {
- width: $unit * $i;
- }
-
- > .off-#{$i}#{$suffix} {
- margin-left: $unit * $i;
- }
- }
-
- // Step through multipliers.
- @each $multiplier in $multipliers {
-
- // Gutters.
- $class: null;
-
- @if ($multiplier != 1) {
- $class: '.gtr-' + ($multiplier * 100);
- }
-
- &#{$class} {
- margin-top: ($guttersRows * $multiplier * -1);
- margin-left: ($guttersCols * $multiplier * -1);
-
- > * {
- padding: ($guttersRows * $multiplier) 0 0 ($guttersCols * $multiplier);
- }
-
- // Uniform.
- &.gtr-uniform {
- margin-top: $guttersCols * $multiplier * -1;
-
- > * {
- padding-top: $guttersCols * $multiplier;
- }
- }
-
- }
-
- }
-
- }
-
- }
|