F
F
frontendo2019-11-25 11:12:24
css
frontendo, 2019-11-25 11:12:24

What is the optimal placement for media queries?

How is it better? Group rule by elements

.component {
  &__elem1 {
    font-size: 12px;

    @media (min-width: 992px) {
      font-size: 15px;
    }
  }
  &__elem2 {
    font-size: 15px;

    @media (min-width: 768px) {
      font-size: 17px;
    }
  }
  &__elem3 {
    font-size: 10px;
  }
  &__elem4 {
    font-size: 9px;

    @media (min-width: 768px) {
      font-size: 10px;
    }
  }
  &__elem5 {
    font-size: 18px;

    @media (min-width: 992px) {
      font-size: 10px;
    }
  }
}

or by media queries
.component {
  &__elem1 {
    font-size: 12px;
  }
  &__elem2 {
    font-size: 15px;
  }
  &__elem3 {
    font-size: 10px;
  }
  &__elem4 {
    font-size: 9px;
  }
  &__elem5 {
    font-size: 18px;
  }

  @media (min-width: 768px) {
    &__elem2 {
      font-size: 17px;
    }
    &__elem4 {
      font-size: 10px;
    }
  }
  @media (min-width: 992px) {
    &__elem1 {
      font-size: 15px;
    }
    &__elem5 {
      font-size: 10px;
    }
  }
}

Is there an article out there somewhere that explains this?

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