https://v5.bootcss.com/docs/layout/columns/#reordering
我们需要显示的视觉效果和源码中显示的先后顺序不一致时,可以对格栅的列重新排序。
使用 .order-
类名来排序,例如.order-1
、.order-md-2
。
示例1
示例2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-9 order-2" style="background-color: gray;">
<h5>这是文章列表</h5>
<ul>
<li>文章标题一</li>
<li>文章标题二</li>
<li>文章标题三</li>
</ul>
</div>
<div class="col-md-3 order-1" style="background-color: red;">
<h5>导航栏</h5>
<ul>
<li>首页</li>
<li>编辑文章</li>
<li>我的</li>
</ul>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous">
</script>
</body>
</html>