Doubts about the media querys! [closed]

0

Let's say you have a fairly large CSS sheet and when I finish styling HTML , I'll do the responsive part of the page.

My problem is that when I start using the media query , all the stylization and programming I've done for the page elements begin to interfere with the media query I'm creating , getting very difficult to do things. I have to do most of the code again within the media query and this is very complicated. This is because you always have to try to find out why the codes are not working right, having to redo 50% of everything in the query .

I would like to know if you have a best practice so that this does not happen and that you have to write and change what I really want to change in media query     

asked by anonymous 19.10.2018 / 04:25

1 answer

1

A tip I give you is to try to plan your website / system to the maximum before creating it, because in this way you will be able to better determine the paddings, margins, floats, flexboxs, etc., making in the time to adjust in the stockings querys, do not have as much "re-work".

Use for example the following queries:

// Dispositivos extra small (telefones em modo retrato, com menos de 576px)
// Sem media query para 'xs', já que este é o padrão, no Bootstrap.

// Dispositivos small (telefones em modo paisagem, com 576px ou mais)
@media (min-width: 576px) { ... }

// Dispositivos médios (tablets com 768px ou mais)
@media (min-width: 768px) { ... }

// Dispositivos large (desktops com 992px ou mais)
@media (min-width: 992px) { ... }

// Dispositivos extra large (desktops grandes com 1200px ou mais)
@media (min-width: 1200px) { ... }

Always think of the minimum width of each of them, before reaching the breakpoint, because in this way, you do not make several adjustments within a media query so after resizing some more, find that you need another adjustment, an example: @media (min-width: 1200px) { ... } , you use 1200px as the basis for your responsiveness and not for example 1920px, so by setting to 1200px that is the breakpoint, you will know that all other resolutions above that will be working.

Bonus Tip: I do not know if you use some kind of CSS framework like Bootstrap for example, but I highly recommend and use it even more for the Grids and other classes that already help in responsiveness in the writing of the HTML code, without having to try so hard with several lines of code after using pure CSS.

I hope to have helped, strong embrace and success!

    
19.10.2018 / 05:11