線上書籍

Home

111網頁前端設計工程師培訓班

Bootstrap的網格系統(Grid System),是使用flexbox建構,使用容器(container)、列(rows)、欄(columns)
  1. container > row > col
  2. 每列有12欄
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Grid System</title> <!-- Bootstrap CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous"> </head> <Style> html, body { height: 100%; } .container { border: 0px solid; background-color: #dbdbdb; min-height: 100%; height: 100% } .col { background-color: #ccffff; } .col-2 { background-color: #6666ff; } </style> <body> <div class="container"> <div class="h-100 row"> <div class="col-2"> 左欄 </div> <div class="col"> 內容區 </div> <div class="col-2"> 右欄 </div> </div> </div> <!-- Bootstrap JS --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script> </body> </html>

 

欄的斷點

  xs
<576px sm
≥576px md
≥768px lg
≥992px xl
≥1200px xxl
≥1400px .container class樣式
None
(auto)
540px
720px  
960px 1140px 1320px
.col-* .col-sm-*
.col-md-*  
.col-lg-* .col-xl-* .col-xxl-*

 

ex:將之設定為col-lg,則超過 992px時,有作用