WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Bootstrap 4 - Grid System


Grid structures allow you to create advanced layouts the usage of rows and columns. The Bootstrap grid machine could have as much as 12 columns, and you may specify how these columns scale for exclusive viewport sizes.

Working of Grid System

  • Rows must be placed within a .Field magnificence for correct alignment and padding.

  • For responsive width use .Box elegance and for constant width across all viewport, use the .Field-fluid class.

  • Use rows to create horizontal companies of columns.

  • Content must be positioned inside the columns, and handiest columns may be the instant kids of rows.

  • Columns incorporate padding for controlling the gap among them.

  • If you area extra than 12 columns in a row, then the columns could be positioned in a new line.

  • Columns create gaps between column content via padding. Therefore, you may get rid of the margin from rows and padding from columns with .No-gutters class at the row.

  • You could make grid machine responsive by way of the usage of five grid breakpoints along with extra small, small, medium, huge, and extra big.

    Grid Options

    Extra small <576px Small ≥576px Medium ≥768px Large ≥992px Extra large ≥1200px
    Grid conduct Horizontal always Collapsed to start, horizontal above breakpoints
    Max box width None (auto) 540px 720px 960px 1140px
    Class prefix .Col- .Col-sm- .Col-md- .Col-lg- .Col-xl-
    Number of columns 12
    Gutter width 30px (15px on every side of a column)
    Nestable Yes
    Column ordering Yes

    Basic Grid Structure

    Following is fundamental shape of Bootstrap 4 grid −

    <div magnificence = "box">
       <div magnificence = "row">
          <div magnificence = "col-*-*"></div>
          <div magnificence = "col-*-*"></div>
       </div>
       
       <div elegance = "row">
          <div elegance = "col-*-*"></div>
          <div magnificence = "col-*-*"></div>
          <div elegance = "col-*-*"></div>	  
       </div>
       
       <div elegance = "row">...</div>
    </div>

    Following is an example of Bootstrap four grid system −

    <html lang = "en">
       <head>
          <!-- Meta tags -->
          <meta charset = "utf-eight">
          <meta call = "viewport" content = "width = tool-width, preliminary-scale = 1, reduce-to-healthy = no">
          
          <!-- Bootstrap CSS -->
          <hyperlink rel = "stylesheet" 
             href = "https://stackpath.Bootstrapcdn.Com/bootstrap/4.1.3/css/bootstrap.Min.Css" 
             integrity = "sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" 
             crossorigin = "nameless">
          <identify>Bootstrap 4 Example</title>
          </style>
             .Grid_system  div[class^="col"] 
                border: 1px strong white;
                background: #e4dcdc;
                text-align: center;
                padding-top: 5px;
                padding-bottom: 5px
             
          </style>
       </head>
       
       <frame>
          <div elegance = "grid_system">
             <div magnificence = "row">
                <div class = "col-sm-1">.Col-sm-1</div>
                <div magnificence = "col-sm-1">.Col-sm-1</div>
                <div magnificence = "col-sm-1">.Col-sm-1</div>
                <div elegance = "col-sm-1">.Col-sm-1</div>
                <div elegance = "col-sm-1">.Col-sm-1</div>
                <div elegance = "col-sm-1">.Col-sm-1</div>
                <div elegance = "col-sm-1">.Col-sm-1</div>
                <div magnificence = "col-sm-1">.Col-sm-1</div>
                <div magnificence = "col-sm-1">.Col-sm-1</div>
                <div magnificence = "col-sm-1">.Col-sm-1</div>
                <div magnificence = "col-sm-1">.Col-sm-1</div>
                <div class = "col-sm-1">.Col-sm-1</div>
             </div>
             
             <div class = "row">
                <div class = "col-sm-3">.Col-sm-3</div>
                <div elegance = "col-sm-3">.Col-sm-3</div>
                <div elegance = "col-sm-three">.Col-sm-three</div>
                <div class = "col-sm-three">.Col-sm-three</div>
             </div>
             
             <div class = "row">
                <div class = "col-sm-4">.Col-sm-4</div>
                <div elegance = "col-sm-four">.Col-sm-4</div>
                <div magnificence = "col-sm-4">.Col-sm-4</div>
             </div>
             
             <div class = "row">
                <div elegance =" col-sm-3">.Col-sm-3</div>
                <div magnificence = "col-sm-three">.Col-sm-three</div>
                <div magnificence = "col-sm-6">.Col-sm-6</div>
             </div>
             
             <div class = "row">
                <div magnificence = "col-sm-5">.Col-sm-5</div>
                <div class = "col-sm-7">.Col-sm-7</div>
             </div>
             
             <div elegance = "row">
                <div elegance = "col-sm-6">.Col-sm-6</div>
                <div class = "col-sm-6">.Col-sm-6</div>
             </div>
             
             <div magnificence = "row">
                <div class = "col-sm-12">.Col-sm-12</div>
             </div>
          </div>
          
          <!-- jQuery first, then Popper.Js, then Bootstrap JS -->
          <script src = "https://code.Jquery.Com/jquery-three.3.1.Slender.Min.Js"
             integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" 
             crossorigin = "anonymous">
          </script>
          
          <script src = "https://cdnjs.Cloudflare.Com/ajax/libs/popper.Js/1.14.3/umd/popper.Min.Js" 
             integrity = "sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" 
             crossorigin = "anonymous">
          </script>
          
          <script src = "https://stackpath.Bootstrapcdn.Com/bootstrap/four.1.3/js/bootstrap.Min.Js" 
             integrity = "sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" 
             crossorigin = "nameless">
          </script>
          
       </frame>
    </html>

    It will produce the subsequent result −

    Bootstrap four Example .Grid_system div[class^="col"] border: 1px strong white; background: #e4dcdc; textual content-align: center; padding-top: 5px; padding-bottom: 5px
    .Col-sm-1
    .Col-sm-1
    .Col-sm-1
    .Col-sm-1
    .Col-sm-1
    .Col-sm-1
    .Col-sm-1
    .Col-sm-1
    .Col-sm-1
    .Col-sm-1
    .Col-sm-1
    .Col-sm-1
    .Col-sm-three
    .Col-sm-three
    .Col-sm-3
    .Col-sm-3
    .Col-sm-4
    .Col-sm-4
    .Col-sm-4
    .Col-sm-3
    .Col-sm-three
    .Col-sm-6
    .Col-sm-five
    .Col-sm-7
    .Col-sm-6
    .Col-sm-6
    .Col-sm-12