This post explains about grid layout in Bootstrap.We can have at most 12 columns and infinite rows using bootstrap on a page.
col-xs-* for extra smaller devices
col-sm-* for smaller devices
col-md-* for medium devices
col-lg-* for larger devices
* represents a number between 1-12 since we can ave at most 12 columns
col-xs-2 means this column will span on two columns of bootstrap.
<!DOCTYPE html>
<html lang="en">
<head>
<link href="css/style.css" rel="stylesheet">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>My First Bootstrap Application</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
</head>
<body>
<h3 class="head">This page contains columns.
In smaller devices such as tablets all four columns will be in the same row
and in extra small devices such as mobile one row contain 2 columns. </h3>
<div class="container">
<div class="row">
<div class="col-sm-3 col-xs-6 col1">
<h1>Abishek</h1>
</div>
<div class="col-sm-3 col-xs-6 col2" >
<h1>Shashank</h1>
</div>
<div class="col-sm-3 col-xs-6 col3">
<h1>Abhinav</h1>
</div>
<div class="col-sm-3 col-xs-6 col4">
<h1>Atal</h1>
</div>
</div>
</div>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.js"></script>
</body>
</html>
Style.css
.col1{
background: red;
}
.col2{
background: green;
}
.col3{
background: yellow;
}
.col4{
background: blue;
}
.head{
background: yellow;
}
col-xs-* for extra smaller devices
col-sm-* for smaller devices
col-md-* for medium devices
col-lg-* for larger devices
* represents a number between 1-12 since we can ave at most 12 columns
col-xs-2 means this column will span on two columns of bootstrap.
<!DOCTYPE html>
<html lang="en">
<head>
<link href="css/style.css" rel="stylesheet">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>My First Bootstrap Application</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
</head>
<body>
<h3 class="head">This page contains columns.
In smaller devices such as tablets all four columns will be in the same row
and in extra small devices such as mobile one row contain 2 columns. </h3>
<div class="container">
<div class="row">
<div class="col-sm-3 col-xs-6 col1">
<h1>Abishek</h1>
</div>
<div class="col-sm-3 col-xs-6 col2" >
<h1>Shashank</h1>
</div>
<div class="col-sm-3 col-xs-6 col3">
<h1>Abhinav</h1>
</div>
<div class="col-sm-3 col-xs-6 col4">
<h1>Atal</h1>
</div>
</div>
</div>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.js"></script>
</body>
</html>
Style.css
.col1{
background: red;
}
.col2{
background: green;
}
.col3{
background: yellow;
}
.col4{
background: blue;
}
.head{
background: yellow;
}
Output:
0 comments:
Post a Comment