N
N
Nadia2018-01-11 20:12:00
Sass
Nadia, 2018-01-11 20:12:00

How to shorten mixin c media queries in sass?

Good afternoon.
There is this mixin:

=default-padding($media)
  @if $media == small
    @media only screen and (max-width: $small - 1)
      padding-top: 60px
  @if $media == medium
    @media only screen and (min-width: $small) and (max-width: $medium - 1)
      padding-top: 80px
  @if $media == portrait
    @media only screen and (min-width: $medium) and (max-width: $large - 1)
      padding-top: 100px
  @if $media == desktop
    @media only screen and (min-width: $large)
      padding-top: 120px

I use it like this:
.wrapper-hor
  +default-padding(small)
  +default-padding(medium)
  +default-padding(portrait)
  +default-padding(desktop)

Question: is it possible to declare/use the mixin in some other way so that the code is shorter.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question