@media coming into conflict

Asked

Viewed 75 times

0

Hello, I would like to know why some commands that belong to a @media are influencing and changing the same command in a @media different. For example, when I put a "width: 30%" in some photo on @media (min-width: 1200px), it changes the size of that same photo also on @media (min-width: 1500px). I found that in some cases, the problem is solved if I put a !important in the element of @media affected, but this does not always resolve. I am organizing the CSS as follows:

  • Desktops-1 (min-width: 1500px);
  • Desktops-2 (min-width: 1200px); and
  • Tablets-1 (min-width: 1000px).

I intend to continue putting more specific resolutions to hold, but this bug is in the way.

  • It will depend on the selectors you use and the order you apply, without seeing your CSS and the selectors you are using we have no way to respond, you should provide a READY example that we can test so we can help you.

  • Your problem is explained in this answer https://answall.com/questions/351972/media-queries-n%C3%A3o-funciona-medidas-informadas/351977#351977 in your CSS sheet should first come the 1000px, then the styles of the 1200 and at the end of the 1500 and so on, the link has more details

  • @hugocsl can also be, or it can be only the order or priority of selectors, there is no way to state anything, there is no code in the question.

1 answer

0

You are using min-width: for example a device with 1500px resolution will enter all previous validations, example min-width: 700px, min-width: 1200px, etc.

You can arrange this in two ways using max-width: 700px, and go limiting by device that contains the resolution until the given resolution. (I use so and dispense with min-width).

Or combine the two options example: (min-width: 768px) and (max-width: 979px) There you guarantee resolution devices between 768px to 979px(replace with the values that best suit you)

  • 1

    thanks, I tried here and it worked

Browser other questions tagged

You are not signed in. Login or sign up in order to post.