How to create Bootstrap Grid System - WPB Tutorials

Wednesday, 21 February 2018

How to create Bootstrap Grid System

Download Bootstrap



Grid Classes

The Bootstrap grid system has four classes:
  1. xs (for phones - screens less than 768px wide)
  2. sm (for tablets - screens equal to or greater than 768px wide)
  3. md (for small laptops - screens equal to or greater than 992px wide)
  4. lg (for laptops and desktops - screens equal to or greater than 1200px wide)
The classes above can be combined to create more dynamic and flexible layouts.

Basic Structure of a Bootstrap Grid

<div class="row">
  <div class="col-*-*"></div>
  <div class="col-*-*"></div>
</div>


Three Equal Columns


Code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Boostarp Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/bootstrap.min.js"></script>
</head>
<style>.c1{background-color:yellow;color:#000;}.c2{background-color:black;color:#fff;}.c3{background-color:grey;color:#000;}</style>
<body>

<!--First we take container that our grid will responsive fixed width container-->

<div class="container">
<div class="row">
<div class="col-sm-4 c1">1</div>
<div class="col-sm-4 c2">2</div>
<div class="col-sm-4 c3">3</div>
</div>
</div>


</body>
</html>

Two Unequal Columns

Code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Boostarp Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/bootstrap.min.js"></script>
</head>
<style>.c1{background-color:yellow;color:#000;}.c2{background-color:black;color:#fff;}.c3{background-color:grey;color:#000;}</style>
<body>

<!--First we take container that our grid will responsive fixed width container-->

<div class="container">
<div class="row">
<div class="col-sm-4 c1">1</div>
<div class="col-sm-8 c2">2</div>
</div>
</div>


</body>
</html>


No comments:

Post a Comment

HTML Elements