Explanation
In the code above, we used the following classes to create the grid:
container
: this class creates a centered container with a fixed width.
row
: this class creates a horizontal row to contain columns.
col-md-4
: this class creates a column that takes up 4 of the 12 available grid columns on medium-sized screens. The md
prefix stands for medium-sized screens. On smaller screens, the columns will stack vertically, and on larger screens, they will take up more columns as specified by their respective classes.
Use
The Bootstrap grid system can be used to create a variety of layouts, from simple rows and columns to more complex designs with nested rows and columns.
Important Points
- The Bootstrap grid system is based on a 12-column layout.
- Columns in a row must add up to 12 columns or less.
- The responsive classes (
col-sm-
, col-md-
, col-lg-
, col-xl-
) can be used to create responsive layouts that display differently on various screen sizes.
- You can nest rows and columns to create more complex layouts.
Summary
The Bootstrap grid system is a flexible and responsive way to create layouts for your website. By using the .container
, .row
, and .col-*
classes, you can create a variety of layouts that look great on any screen size.