You doubt the media!

Asked

Viewed 43 times

0

Suppose you have a sheet of CSS reasonably large and once the stylization of the HTML, I’ll do the responsive part of the page.

My problem is when I start using medias query, all the stylization and programming I did for the page elements begin to interfere in the media query which I am creating, getting very difficult to do things. I have to do most of the codes again within the media query And it’s very complicated. This is because you always have to try to figure out why the codes are not working right, having to redo 50% of everything inside the query.

I wanted to know if you have a better practice so that this doesn’t happen and you have to write and change what I really want to change in media query

  • without a practical example it’s hard to help, make an example to understand, because I don’t have this problem... I’ve tried to use some framework that already treats this, like bootstrarp or material?

  • You’re putting your @media rules as the first things in your CSS, or you’re putting them in the last lines of CSS?

  • Hugo, I’m using at the end of CSS.

1 answer

1


One tip I give you is to try to plan your website/ system to the maximum before creating it, because this way you will be able to better determine the paddings, margins, floats, flexboxs, etc, causing when adjusting in the medias querys, not so much "re-work".

Use for example the following medias querys:

// 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 about the minimum width of each of them, before reaching the "breakpoint", because this way, you do not make several adjustments within a media query for after you resize a little more, find that you need another adjustment, an example: @media (min-width: 1200px) { ... }, you use 1200px as the basis for your responsiveness and not 1920px for example, so by adjusting to 1200px which is the breakpoint, you will know that all other resolutions above that will be working.

Bonus Tip: I don’t know if you use some kind of CSS framework like Bootstrap for example, but I highly recommend the use, even more because of the question of Grids and other classes that already help in the responsiveness in the own writing of HTML code, without you having to work so hard with multiple lines of code later via pure CSS.

I hope I helped, strong hug and success!

  • Tendi amigo... I do not use any flamework, starting now and before starting with flamework, I want to learn to do without needing them first... But this methodology you’re talking about is bootstrap right?

  • No, this methodology that I passed is average normal querys, of course if you use the bootstrap it will help, but in the part of the classes that you put in HTML, except for this, everything that I gave you to do without the bootstrap.

  • Tendi... I’m doing it here the way I said, going from 1366px down... Only by the time it gets to 1050, it starts to break things, then I have to put a media query already there... In the designer of my elements is not giving to put only the measures that you are passing these 4... because there are breakpoints in this intersection, you know?

  • Why don’t you use the media querys I gave you? You need to adjust only those 4 (four): @media (min-width: 576px) { ... } @media (min-width: 768px) { ... } @media (min-width: 992px) { ... } @media (min-width: 1200px) { ... } Otherwise, you did something wrong when coding your site/system

  • i made an OPTIN, from a look... I only used 2. https://pastebin.com/raw/aLrjQSxa

  • @Tonyivan put on https://codepen.io/pen/ for a better view

  • https://codepen.io/T0ny_/pen/OBZaKY?editors=1100

  • But what exactly is the problem? For here it worked well in all resolutions.

  • In codepen works well, but if I do this all there only in Rome and then go see in firefox, some things get smaller or bigger.... The problem is in the browsers it seems... It seems that Rome and firefox are not understand the same language, it’s like your put 10px on Rome and pro firefox it understands how 8px or 7px... tendeu?

  • But this is normal, will not always appear equal in different browsers, because the rendering of each is different, for this, there are the "webkits", take a read in this article

  • Tendi... But in my example, my problem is with firefox, I will have to use in all this -Moz-? -Moz-margin: 10px 10px;

  • I recommend that you search articles/lessons about Webkit for Firefox, because Webkit is only for some events in which there are no compatibilities, strong hug and success!

  • Tend... Obg by patience and understanding my friend... Stay with God! hug!

Show 8 more comments

Browser other questions tagged

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