Is there a standard for Media Querie application?

Asked

Viewed 124 times

0

I’m starting to learn now about Media Querie and I have a doubt I haven’t seen the answer.

Is there any standard in the media querie application ?

It is correct to have a media-querie.css file with all modifications or the correct one would involve the whole code in blocks of media-queries, being that for example, the index.css file, would have inside it a block of media-querie in 360px, another block with 960px etc, both with all page css code.

Or is there yet another pattern ?

Thank you.

  • There is a pattern yes, it’s called BOOTSTRAP. Have you ever heard of?

  • In this case it’s a framework, and I don’t want to go into this approach, I want to apply some pattern to my project that isn’t a framework, and from what I saw in the bootstrap documentation, they follow a pattern, only of them using mixins to create the breackpoints. But thank you so much for the tip.

  • @Leandro and Bootstrap is standard of what? Not even Bootstrap 3 and 4 have the same values as Breacking Point in Media Querie... as it will be standard for anything. Not even Bootstrap he asks... there’s a million more Grids out there, don’t get stuck with Bootstrap

  • Amigo @hugocsl, this question I raised here is not a duplicate of what you put as a suggestion, because there the question is about measures and my question is about pattern of creation and application. And in this matter of bootstrap being a standard, no one said that it is a STANDARD, I said that they have the THEIRS standard and that’s what I’m trying to understand here, if THERE is any standard for implementing media queries or each one does it the way you think best.

  • as a Hare of yours, I will comment here just because there are 2 more Leandros commenting here and what the first commented has nothing to do, alias... disregard

  • @hugocsl I wanted to be a little sarcastic, because Bootstrap is the one that governs the CSS architecture of most hj sites. And it is unthinkable hj in day you work professionally without the aid of frameworks.

  • About whether there’s a pattern I think it’s clear in the other question that there’s no pattern. About Bootstrap I just made a comment about who thinks Bootstrap is mandatory and in the case is not, it’s just another Grid like any other. About Csss may have good practice regarding indexing, but not about the size of Querie Media

  • I haven’t used bootstrap for a long time... only if it’s for codating an admin panel, other than that, it’s not mandatory for layouts

  • Leandro thanks for the sarcastic reply ... helped me a lot. Thank God there are people like @hugocsl and Leandro Ruel to help people who don’t know anything.

  • 2

    Leonardo since you are starting, don’t get attached to "crutches" enjoy and study how to do things in hand first. Half of Bootstrap’s questions here on the site are from people who from crtl+c and Ctrl+v and then can’t do what they want because they have no idea what they’re doing. It starts with the base, and not with ready-made model that you don’t understand. It’s only a tip if you intend to take the studies forward.

  • Guy what I want from the beginning to say is that wanting or not you WILL HAVE to learn to deal with Bootstrap, Materialize, Bulma, etc... Any company that wants to have productivity in developing layouts use them. Like the boy said up there that Bootstrap is not mandatory, I’m not and he doesn’t decide that’s the market.

  • @Leandro Mandatory or not you will not be able to use a tool productively unless you realize the things she is doing.

Show 8 more comments

2 answers

1

I will give you an answer based on what I do in my projects, in fact I do not specify a specific pattern of size in my media queries, what I do is to develop a layout as fluid as possible with the help of some CSS technologies (thanks flexbox)and in my tests, I use a responsiveness emulator, when the layout reaches a certain width and my layout breaks at that point, I insert a breakpoint at that width, Ex: I have a slider and in desktop size behaves normally showing 3 images, when the width is at 320px the slider "breaks" at 3 lines, enter a breakpoint @media all and (max-width: 320px){} and there I put the rules so that my slider is showing only one image at a time.

0


OOCSS

As far as I know, the OOCSS (Object-Oriented CSS) convention says it’s best to create a library with separate CSSS components.

Therefore, in an exemplary way, one should create a separate style sheet for each component of a project, such as buttons, navbar, Typography, etc...

Graphic example:

root
|
+-- index.html
|
+-- css/main.css; buttons.css; navbar.css; typography.css...
|
+-- js/

Fictitious situation with buttons

That way, if your need was to apply breakpoints (media queries) to buttons, you would create a Buttons.css file that would contain the rules for the various sizes of buttons.

What the style sheet of a button component would look like:

.btn {
    width: x;
}

    @media only screen and (max-width: 682px;){
        .btn-y {
            width: y;
        }
    }

    @media only screen and (max-width: 960px;){
        .btn-z {
            width: z;
        }
    }

Completion

Modulate your CSS so that each component has its own CSS. So within each style sheet use the breakpoints for the given component.

Still about style sheets, notice that I talked about OOCSS in a shallow way, so I recommend that you research on the subject.

Also, do not take into account the comment of those who speak to use Bootstrap, after all, has no relation to your doubt.

Ps: I have difficulty expressing myself. So, if you still have doubt, comments.

Edit 1: This situation, which I mentioned, applies only at the development stage. Therefore, you would have to use something like preprocessors to combine everything, when finishing the development.

Edit 2: @hugocsl brought this link which explains how to behave, when publishing.

  • Young this methodology several Csss is only valid for development environment, because it facilitates maintenance etc, but when publishing the practice is to minimize everything in a CSS only, so avoid an excessive number of requests and decrease the response time of the page. Multiple Csss tb is not good practice for websites as well as the use of @Mports of style sheets. So the best is just a CSS? No :) this question is based on opinions in my view. Links https://css-tricks.com/one-two-three/ and https://stackoverflow.com/questions/2336302/single-huge-css-file-vs-multiple-smaller-specific-css-files

  • And just to say that I’m not totally against more than a CSS the option of a CSS for "Above the Fold" and another for "Under the Fold" is something I like!

  • Yes, @hugocsl , it is not right to make too many requests. And, like CSS Tricks and you talk, the methodology can be good only in development environment (something I didn’t mention). However, would my answer still be correct if his situation is in Velopment? Will fit one 'Edit' with the link to CSS Tricks and another to explain this deployment and Development stop?

  • Yes young man, feel free to improve your answer, by the way, nor was I the one who denied you, just gave my opinion on the subject...

Browser other questions tagged

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