CSS Grid Framework System

Asked

Viewed 167 times

0

I am new to the CSS Framework branch, my question is as follows. Tool independent (Bootstrap, Materialize, etc.) how is the process of creating a website using CSS grid? Not the operation of the grid itself, but the applicability in practice, the documentation does not talk about it. For example, roughly it was like this (I believe): The programmer made several layouts for various devices, the script identified the device and then presented the proper layout. Today we know it’s not so, but how to create a layout already thinking about the different devices ? Does the Framework do it alone? He’s rendering everything himself? In the creation process I should follow the above reasoning (to create multiple layouts) and go testing with the columns specified for the device? What is the flow of creation ? Sorry if it was too long the question and if it was confusing rrss.. Thank you !

  • If you have already analyzed any screen that uses boostrap, you will see that within the classes in HTML tags there are several names like col-sm-12. This represents the size of the grid, it adapts with the size of the screens and devices due to the CSS and JS libraries that comes along with Bootstrap. Here you will get more information about Bootstrap.

  • 1

    The answer http://answall.com/a/8920/3635 seems to respond well to the problem, explains that by resizing the grids already self-update as you previously set them and explain how to use them. If there’s something missing please comment.

1 answer

1

I will explain using bootstrap as a reference because it is the framework I know best.

It divides any space within an element into 12 columns no matter the total size of the element, i.e.:

<body> // eu tenho 12 colunas dentro do body
    <div> // eu tenho 12 colunas dentro da primeira div
        <div> // eu tenho 12 colunas dentro da segunda div
        </div>
    </div>
</body>

The question of responsiveness comes when we mark how many columns an element is wide for a given screen size.

  • We have the column marking col-lg from 1 to 12 for large screens
  • We have the column marking col-md from 1 to 12 for medium screens
  • We have the column marking col-sm from 1 to 12 for small screens
  • We have the column marking col-xs from 1 to 12 for mobile screens

Example:

<div id="pai">
    <div id="div1" class="col-lg-10 col-md-8 col-sm-6 col-xs-12"></div>
    <div id="div2" class="col-lg-2 col-md-4 col-sm-6 col-xs-12"></div>
</div>
  • On a large screen, the filho1 will occupy 10 columns of pai as long as the filho2 will occupy 2 columns of pai.
  • On a medium screen, the filho1 will occupy 8 columns of pai as long as the filho2 will occupy 4 columns of pai.
  • On a small screen, the filho1 will occupy 6 columns of pai as long as the filho2 will occupy 6 columns of pai.
  • On a mobile screen, the filho1 will occupy 12 columns of pai as long as the filho2 will occupy 12 columns of pai.

And how does he know which column he should apply to the screen size?

It’s thanks to a resource called Media query that you can apply certain css to a screen size that you want.

Example, taken from bootstrap 3 source code without changing anything:

@media (min-width: 768px) {
    .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 {
        float: left;
    }
    .col-sm-12 {
        width: 100%;
    }
    ...
}

Until the screen on which the website opens is not at least the size of 768px, which is the size that the bootstrap considers for small screens, classes col-sm- do not respond to not overwrite the styles of the mobile screen classes, the col-xs-. Because as the larger the screen, the classes corresponding to larger sizes will overwrite the smaller size classes.

Ta, beauty. This does not answer your question whether the Framework will do the work of thinking on multiple screens or not.

The answer is no. You still need to think about your multi-screen layout, the framework will make it easy to move between them without having to redirect your user to multiple layouts and especially without having to maintain multiple layout files.

It allows you to adapt the layout to multiple screens without having to reassemble/reorder elements. Only by using the classes can you swap position/column elements as you move from one screen to another, you can determine that the X element will not appear on mobile screens while the Y element will appear only on mobile.

All this using only the classes of grid system and utility classes

Remembering that there are cases that using a css framework with grid system will not satisfy your needs altogether, so do not feel obligated to use one only because the market uses.

I hope I’ve been able to shed some light on the advantage of using a grid system.

  • 1

    The answer is good, but I recommend that if you already have a question with an answer on the subject the best is to mark the question as duplicate using the link [Signal] that is below the question, because if you do not start to have several contents repeated and spread over the same subject, understand as a constructive criticism ;)

  • @Guilhermenascimento I didn’t even look for a question or related answer, I simply put my knowledge to try to help the guy, in a next general question of this I do a search before. Bobiei haha

  • A tip: always look at the comments in the questions, usually the person already points links to duplicates ;) See more

  • @Guilhermenascimento I was already writing the reply when the staff made the comments. I only saw the comments when I finished the reply. When I started answering I didn’t even have that other answer down there.

  • had a comment from Renan (he deleted it) for more than 60 minutes, but yes sometimes it occurs, as said is a tip and not a criticism ... Welcome to the community, show up to chat for a chat, see more ;)

Browser other questions tagged

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