S
S
Sergey Mamenko2017-04-13 15:10:16
css
Sergey Mamenko, 2017-04-13 15:10:16

How do you write media queries in sass?

Good afternoon
Which use case of media queries would be more correct:

.selector {
  @media (width1) {}
  @media (width2) {}
}

or
.selector { 
}
@media (width1) {.selector {}}
@media (width2) {.selector {}}

?
Or does it all depend on convenience and habit and there are no specific rules?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
Z
zooks, 2017-04-13
@bobongida97

The second one is correct.
And the first one is convenient, but then you need to run it through gulp-combine-mq .
Also don't forget about breakpoint-sass.com

A
Andrey Goncharov, 2017-04-13
@agmegadeth

I prefer to write directly in the selector, you can immediately see how the element is being modified, and write less.

E
Egor Zhivagin, 2017-04-13
@Krasnodar_etc

IMHO, this option looks much more readable, especially when there are a lot of styles -

@media (max-width: 1) {
  .selector1{
///стили
  }
}

Of course there are no rules.

A
andead, 2017-04-13
@andead

I usually write like this:

.module {
  font-size: 12px;
  .module-element {
    font-size: 11px;
  }

  @media (...) {
    font-size: 14px;
    .module-element {
      font-size: 12px;
    }
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question