Articles → BOOTSTRAP → Bootstrap Grid

Bootstrap Grid






Purpose







Bootstrap Grid Classes


  1. xs id for phones - screens less than 768px wide
  2. sm is for tablets - screens equal to or greater than 768px wide
  3. md is for small laptops - screens equal to or greater than 992px wide
  4. lg class is used for laptops and desktops having screens equal to or greater than 1200px wide

Example


<!DOCTYPE html>
<html lang="en"
   xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta charset="utf-8" />
      <title></title>
      <link rel="stylesheet" href="bootstrap.css" />
   </head>
   <body>
      <div class="container">
         <div class="row">
            <div class="col-6">Name</div>
            <div class="col-6">City</div>
         </div>
         <div class="row">
            <div class="col-6">Karan</div>
            <div class="col-6">Delhi</div>
         </div>
         <div class="row">
            <div class="col-6">Sumit</div>
            <div class="col-6">Mumbai</div>
         </div>
      </div>
   </body>
</html>


  1. A new row is created using the class "row".
  2. Each row is divided into 2 columns (6 parts each)


Picture showing the output of the Bootstrap grid
Click to Enlarge


Using Wild Card




<!DOCTYPE html>
<html lang="en"
   xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <meta charset="utf-8" />
      <title></title>
      <link rel="stylesheet" href="bootstrap.css" />
   </head>
   <body>
      <div class="container">
         <div class="row">
            <div class="col-lg-6">Name</div>
            <div class="col-lg-6">City</div>
         </div>
         <div class="row">
            <div class="col-lg-* border">Karan</div>
            <div class="col-lg-12">Delhi</div>
         </div>
         <div class="row">
            <div class="col-lg-6">Sumit</div>
            <div class="col-lg-6">Mumbai</div>
         </div>
      </div>
   </body>
</html>




Picture showing the output of the Bootstrap grid using wild cards
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Monday, August 30, 2021

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250