在新的空白选项卡中打开输出(单击“显示输出”按钮旁边的箭头)并调整浏览器窗口的大小以了解 Bootstrap 响应式网格系统的工作原理。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Two Column Grid Layouts for Tablets and Desktops</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script>
<style>
/* Some custom styles to beautify this example */
.demo-content{
padding: 15px;
font-size: 18px;
background: #dbdfe5;
margin-bottom: 15px;
}
.demo-content.bg-alt{
background: #abb1b8;
}
</style>
</head>
<body>
<h2 class="text-center mt-3">Bootstrap Responsive Layout</h2>
<div class="text-center my-3">Open the output in a new blank tab (Click the arrow next to "Show Output" button) and resize the browser window to understand how the Bootstrap responsive grid system works.</div>
<div class="container">
<!--Row with two equal columns-->
<div class="row">
<div class="col-md-6">
<div class="demo-content">.col-md-6</div>
</div>
<div class="col-md-6">
<div class="demo-content bg-alt">.col-md-6</div>
</div>
</div>
<!--Row with two columns divided in 1:2 ratio-->
<div class="row">
<div class="col-md-4">
<div class="demo-content">.col-md-4</div>
</div>
<div class="col-md-8">
<div class="demo-content bg-alt">.col-md-8</div>
</div>
</div>
<!--Row with two columns divided in 1:3 ratio-->
<div class="row">
<div class="col-md-3">
<div class="demo-content">.col-md-3</div>
</div>
<div class="col-md-9">
<div class="demo-content bg-alt">.col-md-9</div>
</div>
</div>
</div>
</body>
</html>
效果如下:
