Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Bootstrap ships with a 12 column grid system. It's a mobile first grid. Meaning that it's designed for you to think about small screen design first. And then think about the larger desktop designs afterwards. And there are four sizes to this grid now. Rather than before, with Bootstrap, where we just had basically, going horizontally across the page or it went vertically. We now have four grid sizes. You can learn all about this grid system, if you go to GetBootstrap.com. Click on the link in the top navigation for CSS. And then click on the link on the side here for the Grid System.
And this will give you a full explanation of how the grid system works, media queries associated with it and so forth. If you scroll on down here to Grid > Options, this is going to explain to you the four sizes of grid that come with Bootstrap. It's worth noting that it starts with the extra small grid system, designed for very small devices like phones. So less than 768 pixels, when your screen is that large, it will be under control of the extra small grid system. And that grid is designed to be horizontal at all times.
Then there's three other sizes that are designed to be horizontal. And at the break points, which are specified underneath the name of each of those grid systems on the top there. Greater than or equal to 768 for small devices. Greater than or equal to 992 pixels for medium devices and greater than or equal to 1200 pixels for large devices. Those are the points where the grid is going to go horizontally across the page. As the grid goes narrower, the small, medium and large grids will simply stack vertically.
So if you think of three boxes going across the page, when you make the page narrower, those three boxes will then stack and go vertically. And if you keep on going down the page here, Bootstrap's going to give you some examples of the grid systems and how they work. I found these all fairly confusing, actually. It took me a little while to understand what Bootstrap is doing. So, I've written an example page for you. We are in chapter 2, and we're going to go to 02 01. You'll find a file here called grid.html. If you will copy that file and then paste it into your Bootstrap folder at the same level as index.html.
Just go ahead and drop in that grid file and then open that up in your browser. You can follow along with me. And you'll see here this is my master example grid. So, what I've tried to do here is, I have built out one row using these various grid systems. And making use of some of the classes that come with Bootstrap, I've tried to demonstrate for you how exactly this grid system works. So this video is being recorded at 1360 by 768 pixels. So, 1360 of course is greater than 1200.
And I've fully maximized my browser here, so at 1360 pixels, all of these grids are going horizontally across the page. As I'm going to make my browser narrower here, you're going to see how these various grid systems start to react. What I have here to show you is this very first row, is actually coded with all four grid systems. And then depending on the screen resolution for the width, it's going to display the name of the grid that's in use inside each of the cells. So, right now it says call, dash, large, dash four in each of those cells.
That's because we're working with the large grid system at the moment. Underneath the other four grids that you see here, are coded with one grid system alone. Either the extra small, the small, the medium, or the large grid. That way you can see how all of the grids can work together. And you also can see how each of those grids are working individually on this page. Alright, so I'm going to now take my screen here off of that maximum. Here we are at something slightly less than 1360 pixels. And as I start to minimize the size of this page here, you're going to notice we get to a break point, which happened right there.
That's probably around 1200 pixels. Watch this top row here very carefully. See how we've gone from the large grid system here. As I pull this corner in just a little bit and we hit that break point. Notice that the contents of those grids now read that it's medium grid. And that's because I have used some of the visibility classes that ship with Bootstrap to hide the words that said large. And show the grids that show medium, so that's how I changed the text. You'll notice the text above here also changed to indicate that we're now at this next break point and we're sort of between 1200 and 992 pixels.
And you'll notice that down here at the bottom of the page, the large grid by itself is now stacking vertically. So the large grid in, in absence of any other forces acting upon it would simply stack vertically like this. Whereas the other grids are still going horizontally across the page. Now, because I combined those grids here in this first bar across the top of the page. You see here that it's now under control of the medium grid system. The large grid system is no longer in effect. So I'm going to make the page smaller again. And we're going to hit another break point here in just a second.
There we go. So, at this break point, we've now passed that 992 pixel break point. We're now at something between 992 and 768 pixels. So we're working on the small grid at this point. So once again, if you take a look at the medium grid or the large grid. These are now stacked vertically across the page. Whereas if you take a look up here at the top of the page, we're now working with the small grid. You'll also notice in my master grid here, I've changed the distribution of those columns along the way.
So, the layout of those columns is changing as I go here. That's certainly not required. But it's an option that you can take advantage of while working with these grid systems. Alright, so now I'm going to make this page a little smaller again. Until I hit my next break point, right around in here somewhere. There we go. So, now we're on the extra small grids system. We're at less than 768 pixels. So, the small, medium and large grids are all going vertically across the page. The extra small grid is still staying horizontal, because remember the extra small grid always stays horizontal.
So as I make this page even narrower, you'll see that even when I get ridiculously narrow like this, I only have a few words across going on the page. My extra small grid is still going horizontally across page, even when the contents they're in are obviously too large for that particular cell. We've actually got content hanging outside of that grid. So, now that you see how this works visually, let's take a look at this in terms of the HTML. So if you will open up grid.html here inside of Sublime text, you'll see exactly how I put this together.
So, I have a little bit of styling up here at the top of the page. This is just for my example. Just to add a little bit more padding and some colors, so that you can see these grids on the page. And then if you scroll on down here into the main body, you'll see the actual code that I've used to put this together. So, here at lines 45 through 48, you'll notice these are paragraphs with various classes that are associated with them. So I have visible large, visible medium, visible small, and visible extra small. These classes are designed to show this particular content only at the media queries that correspond with those various grid sizes.
So I have four sentences that are actually here on the page. And all of the four sentences are loading in the HTML. But only one sentence is being displayed depending where I am and the screen resolution. Likewise down here, starting around line 50 this is the code for these various grids. I'm going to go through all of this code with you. But I just want you to take a quick peek at how this is put together. Notice that we start a row here at line 50. And then inside of that we have our various individual cells.
And those cells are starting at lines 51, 57 and 63. And we had specified here a number of different classes all together. Because remember, you can have multiple classes on an individual HTML element. And we've combined those individual classes, in such a way that the grid is going to change its distribution and its sizing depending on what our immediate query is doing. So that's the master grid there where I've combined all four of those grid systems together. Then further down on the page here, these are the individual examples in which I call only one of the grid systems.
Alright, so it's possible that you can use all four of the grid systems together in what you're doing. Or you can use just one. Or you could use two of the grid systems. Or you can use three of the grid systems. It's completely dependent on your design and what you're trying to achieve from your page. And how you think things look on the page at the various, different resolutions. As to which grid system is the right grid system for you to use, at which particular points in time. It's all very, very subjective. I wish I could give you a lot of great rules and just say just forget about these grids and only use these grids.
But it really boils down to, how do things look and how do you want them presented on various devices. I think you're going to get more of a sense of that as we go through this chapter on the grid system. So in the next video we'll start writing our own grid.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.