xs(用于手机)
sm(用于平板电脑)
md(适用于台式机)
lg(适用于大型台式机)
<div class="row"> <div class="col-*-*"></div> </div> <div class="row"> <div class="col-*-*"></div> <div class="col-*-*"></div> <div class="col-*-*"></div> </div> <div class="row"> ... </div>
创建一行(<div class="row">)。
添加您要在网格中显示的列数(带有相应的.col-*-*类的标签)。
请注意,.col-*-*中的数字应始终为每行总计12、
<!DOCTYPE html> <html lang="en"> <head> <title>Job</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/> </head> <body> <div class="container"> <h1>Grid Example</h1> <div class="row"> <div class="col-md-3"style="background-color:lavender;">Rahul</div> <div class="col-md-3"style="background-color:lavenderblush;">Vijay</div> <div class="col-md-3"style="background-color:lavender;">Kartik</div> <div class="col-md-3"style="background-color:lavenderblush;">Ajeet</div> </div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <title>Job</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/> </head> <body> <div class="container"> <h1>Grid Example</h1> <div class="row"> <div class="col-md-1"style="background-color:lavender;">Rahul</div> <div class="col-md-2"style="background-color:lavenderblush;">Vijay</div> <div class="col-md-4"style="background-color:lavender;">Kartik</div> <div class="col-md-5"style="background-color:lavenderblush;">Ajeet</div> </div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> </body> </html>
.col-(extra small devices-屏幕宽度小于576px)
.col-sm-(small devices-屏幕宽度等于或大于576像素)
.col-md-(medium devices-屏幕宽度等于或大于768像素)
.col-lg-(large devices-屏幕宽度等于或大于992px)
.col-xl-(xlarge devices-屏幕宽度等于或大于1200px)
<!--Control the column width, and how they should appear on different devices--> <div class="row"> <div class="col-*-*"></div> <div class="col-*-*"></div> </div> <div class="row"> <div class="col-*-*"></div> <div class="col-*-*"></div> <div class="col-*-*"></div> </div> <!--Or let Bootstrap automatically handle the layout--> <div class="row"> <div class="col"></div> <div class="col"></div> <div class="col"></div> </div>
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script> </head> <body> <div class="container-fluid"> <h2>Three equal-width columns</h2> <div class="row"> <div class="col" style="background-color:lavender;">.col</div> <div class="col" style="background-color:orange;">.col</div> <div class="col" style="background-color:lavender;">.col</div> </div> </div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script> </head> <body> <div class="container-fluid"> <h1>Unequal Columns</h1> <p>Resize the browser window to see the effect.</p> <p>The columns will automatically stack on top of each other when the screen is less than 576px wide.</p> <div class="row"> <div class="col-sm-4" style="background-color:lavender;">.col-sm-4</div> <div class="col-sm-8" style="background-color:lavenderblush;">.col-sm-8</div> </div> </div> </body> </html>