In this post, I will continue to play with grid sizes based on the last post example.
Firstly, I make a 12 grids, and each grid is for large size device and scales to 1 units (col-lg-1).
The result shows 12 grids in the same size on the desktop size page.
If the window changes from desktop size to tablet size, we will change the grid size from large to medium, too. Therefore, I add additional value "col-md-2" in the class attribute.
As we see, when I change the web page to a tablet size, each grid will scale 2 units to fit in a medium size device.
If we want those grids to fit in a small device, we need to add another class attribute value "col-sm-6".
Change Grid Size From Large To Medium
Firstly, I make a 12 grids, and each grid is for large size device and scales to 1 units (col-lg-1).
The result shows 12 grids in the same size on the desktop size page.
If the window changes from desktop size to tablet size, we will change the grid size from large to medium, too. Therefore, I add additional value "col-md-2" in the class attribute.
As we see, when I change the web page to a tablet size, each grid will scale 2 units to fit in a medium size device.
Change Grid Size From Medium To Small
Then, I create a new grid system which includes four same unit grids to fit both large and medium size device. They are colored in orange.
The result shows four orange grids.
If we want those grids to fit in a small device, we need to add another class attribute value "col-sm-6".
When I change the web page size to a smaller size, I can see the grids change from one rows to two rows. Each grid scale changes from 3 to 6 units.
Nested Grid
If we want to add grids inside a grid, we will need to add a new row inside the parent grid. As the example below, I add a new row under the first grid, and this new row include two grids. One is "first half", and the other one is "other half".
One thing we need to pay attention is that when we nested grid, the parent grid will include 12 columns. That's why I assign the "first half" grid six units, and the same as the "other half".
In another word, if you want to add three grids in the parent grid, you need to scale each nested grid up to four columns.
As the result, the first grid has two pink grids.
Comments
Post a Comment