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-* 中删除数字,并仅在 col 元素上使用 .col 类。 Bootstrap 将识别有多少列,并且每列将获得相同的宽度:</p> <div class="container-fluid"> <div class="row"> <div class="col bg-primary text-white p-3">1 of 2</div> <div class="col bg-dark text-white p-3">2 of 2</div> </div> </div> <br> <div class="container-fluid"> <div class="row"> <div class="col bg-primary text-white p-3">1 of 4</div> <div class="col bg-dark text-white p-3">2 of 4</div> <div class="col bg-primary text-white p-3">3 of 4</div> <div class="col bg-dark text-white p-3">4 of 4</div> </div> </div> </div> </body> </html>