W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h2>顺序</h2> <p>使用 .order 类更改特定 flex 项的视觉顺序。有效的类是从 0 到 12。</p> <p>在不同的屏幕尺寸上使用 .order-sm|md|lg|xl-0-12 来实现这种效果。还可以组合这些类来形成更加灵活的布局。</p> <p>请调整浏览器窗口大小来查看效果。</p> <p><code>.order</code>:</p> <div class="d-flex mb-3"> <div class="p-2 order-3 bg-info">Flex item 1</div> <div class="p-2 order-2 bg-warning">Flex item 2</div> <div class="p-2 order-1 bg-primary">Flex item 3</div> </div> <p><code>.order-sm</code>:</p> <div class="d-flex mb-3"> <div class="p-2 order-sm-3 bg-info">Flex item 1</div> <div class="p-2 order-sm-2 bg-warning">Flex item 2</div> <div class="p-2 order-sm-1 bg-primary">Flex item 3</div> </div> <p><code>.order-md</code>:</p> <div class="d-flex mb-3"> <div class="p-2 order-md-3 bg-info">Flex item 1</div> <div class="p-2 order-md-2 bg-warning">Flex item 2</div> <div class="p-2 order-md-1 bg-primary">Flex item 3</div> </div> <p><code>.order-lg</code>:</p> <div class="d-flex mb-3"> <div class="p-2 order-lg-3 bg-info">Flex item 1</div> <div class="p-2 order-lg-2 bg-warning">Flex item 2</div> <div class="p-2 order-lg-1 bg-primary">Flex item 3</div> </div> <p><code>.order-xl</code>:</p> <div class="d-flex mb-3"> <div class="p-2 order-xl-3 bg-info">Flex item 1</div> <div class="p-2 order-xl-2 bg-warning">Flex item 2</div> <div class="p-2 order-xl-1 bg-primary">Flex item 3</div> </div> <p><code>.order-xxl</code>:</p> <div class="d-flex mb-3"> <div class="p-2 order-xxl-3 bg-info">Flex item 1</div> <div class="p-2 order-xxl-2 bg-warning">Flex item 2</div> <div class="p-2 order-xxl-1 bg-primary">Flex item 3</div> </div> </div> </body> </html>