Bootstrap 4 Container And Grid, What is Bootstrap Grid System ?
Bootstrap 4 Container And Grid:
Fixed Container:
Use .Container class to create a responsive, fixed-width container.
Example:
- <!doctype html>
- <html lang="en">
- <head>
- <!-- here Required meta tags -->
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <!-- here Bootstrap CSS -->
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
- <title>Bootstrap, Hello, world!</title>
- </head>
- <body>
- <div class="container">
- <h1>This Is My First Bootstrap Page</h1>
- <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
- <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,</p>
- </div>
- <!-- here Optional JavaScript -->
- <!-- here jQuery first, then Popper.js, then Bootstrap JS -->
- <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
- </body>
- </html>
Output:
Fluid Container:
Use .Container-fluid for a full width container, spanning the entire width of the viewport.
- <div class="container-fluid">
- <h1>This Is My First Bootstrap Page</h1>
- <p>This Is My First Bootstrap Page.</p>
- </div>
Bootstrap 4 Grid:
What is Bootstrap Grid System?
Bootstrap Grid system provides the quick and Convenient way to create Responsive website layouts. Bootstrap’s grid system uses a set of containers, rows, and columns to layout and align content. The latest Bootstrap 4 version introduces the new mobile-first flexbox grid system that appropriately scales up to 12 columns as the device or viewport size increases.
Grid Classes
.col- (extra small devices ------ 576px)
.col-sm- (small devices ------ 576px)
.col-md- (medium devices ------- 768px)
.col-lg- (large devices ------- 992px)
.col-xl- (xlarge devices ------ 1200px)
Four Equal Columns:
- <div class="container">
- <h1>Four Equal Columns</h1>
- <div class="row">
- <div class="col" style="background-color:lavender;">This is .col</div>
- <div class="col" style="background-color:orange;">This is .col</div>
- <div class="col" style="background-color:lavender;">This is .col</div>
- <div class="col" style="background-color:orange;">This is .col</div>
- </div>
- </div>
Output:
Note: If 2, 3, 4, 5, auto add, and Auto Responsive.....
Two Unequal Responsive Columns:
- <div class="container">
- <div class="row">
- <div class="col-sm-4" style="background-color:blue;">.col-sm-4</div>
- <div class="col-sm-8" style="background-color:red;">.col-sm-8</div>
- </div>
- </div>
Output:
Note: If yous col-sm-6 and col-sm-6, then space 50, 50, and Auto Responsive.....
Thank you.........
shelleyakter
So nice post, Thank You.