W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!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 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-fluid mt-3"> <h1>响应式自动布局列</h1> <p>在 Bootstrap 5 中,有一种简单的方法可以为所有设备创建等宽的列:只需从 .col-lg-* 中删除数字,并仅在 col 元素上使用 .col-lg 类。 Bootstrap 将识别有多少列,并且每列将获得相同的宽度。</p> <p>如果屏幕尺寸小于 992px,列将水平堆叠:</p> <div class="container-fluid"> <div class="row"> <div class="col-lg bg-primary text-white">1 of 2</div> <div class="col-lg bg-dark text-white">2 of 2</div> </div> </div> <br> <div class="container-fluid"> <div class="row"> <div class="col-lg bg-primary text-white">1 of 4</div> <div class="col-lg bg-dark text-white">2 of 4</div> <div class="col-lg bg-primary text-white">3 of 4</div> <div class="col-lg bg-dark text-white">4 of 4</div> </div> </div> </div> </body> </html>