Grid system :
Hello guys ! today we will learn about Grid system in Bootstrap 4 !
Grid system is simply a combination of rows and columns , that helps to create mobile friendly web pages !
Rows :
Rows are horizontal containers that hold the columns. They ensure proper alignment and spacing of columns within a container. Rows are created using the .row class.
cols :
Columns are the vertical containers within a row. They allow you to divide the row into multiple equal or unequal sections. Columns are created using the .col-{breakpoint}-{number} class.
The {breakpoint} refers to the specific device size where the column behavior changes, such as xs for extra-small (phones), sm for small (tablets), md for medium (desktops), lg for large (desktops), and xl for extra-large (large desktops).
The {number} represents the number of columns the element should span within its parent row. For example, .col-md-6 would create a column that spans 50% of the parent container on medium-sized screens.
Example :
PHP Example
Edit it yourself
<!DOCTYPE html>
<html lang="en">
<head>
<title>Grid Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.4/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
<style>
.border
{
border:1px solid black;
}
</style>
</head>
<body>
<div class="row border">
<div class="col">.col</div>
<div class="col">.col</div>
<div class="col">.col</div>
</div>
</body>
</html>