V
V
vladimir_html2017-08-27 09:33:29
css
vladimir_html, 2017-08-27 09:33:29

Is inheritance mandatory in media queries?

I type with less. Began to do adaptively - media queries are not read. Moved to the end of less, still not readable. I decided just for fun to do with inheritance:

@media screen and (max-width: 767px) {

  body {
    .header {
      .logo {
        flex-direction: column;
        .left_part {
          width: 100%;
        } //left_part
      }// logo
    }// header
  }// body
}

So what? Earned. Is inheritance required or am I doing something wrong?
UPD in the browser inspector are not displayed at all, even the strikethrough ones

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Talalaev, 2017-08-27
@neuotq

In addition to cascading (and priority according to a more precise indication), the principle of sequence works.
Thus, your styles specified in media queries work, but then they are overwritten by styles that match the same elements, but are listed below.
In short, it's best to place all media queries at the end of the file, or right after the base style definitions, so the media queries are an addition that, when triggered, will override the main class.
A separate discussion of the property distribution technique, probably the simplest one, will define basic properties in css classes (sometimes + for mobile vertical screens), and then expand them in media queries for each higher screen resolution. From simple to complex.
PS but in general at your leisure I advisestudy .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question