A
A
Andrej Sharapov2019-07-05 12:25:49
Sass
Andrej Sharapov, 2019-07-05 12:25:49

How to rebuild a mixin?

Actually, subject.
I'm trying to make a construction for displaying font-size for media queries, where $queries: $sm, $md, $lg, $xl;- screen resolutions, $sizes: $fzh6, $fzh5, $fzh4, $fzh3, $fzh2, $fzh1;- font size.
But in an attempt to put together - confused even worse.

@each $query in $queries {
    @media (max-width: #{$queries}) {
        @mixin media-sizes($sizes) {
            @for $i from 1 through 6 {
                h#{$i} {
                  font-size: $sizes;
                }
            }
        }
    }
}

Help rebuild please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Flying, 2019-07-05
@Madeas

In general, everything is very simple:

@each $query in $queries {
    @media (max-width: #{$query}) {
        @for $i from 1 through 6 {
            h#{$i} {
              font-size: nth($sizes, $i);
            }
        }
    }
}

However, it is better to store the dimensions in a map, this will simplify the code:
$sizes: (
  h6: $fzh6, 
  h5: $fzh5, 
  h4: $fzh4, 
  h3: $fzh3, 
  h2: $fzh2, 
  h1: $fzh1
);

@each $query in $queries {
    @media (max-width: #{$query}) {
        @each $tag, $size in $sizes {
            #{$tag} {
              font-size: $size;
            }
        }
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question