我們知道,在使用Bootstrap柵格的時候,我們可以對網頁方便的進行模組分割。 Bootstrap 包含了一個響應式的、行動裝置優先的、不固定的網格系統,可以隨著裝置或視窗大小的增加而適當地擴展到12列。
它包含了用於簡單的佈局選項的預定義類,也包含了用於生成更多語義佈局的功能強大的混合類。如果要2等分,使用col-md-6即可;要3等分,使用col-md-4即可;但如果我們要5等分或8等分怎麼辦呢?下面的範例是bootstrap五等分佈局:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <!--视口的设置,让网页能等比例的缩放到对应设备中--> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <!--告诉ie浏览器用最新内核去渲染网页--> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <title>Document</title> <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css"> <style type="text/css"> .col-xs-1-5, .col-sm-1-5, .col-md-1-5, .col-lg-1-5 { position: relative; min-height: 1px; padding-right: 10px; padding-left: 10px; } .col-xs-1-5 { width: 20%; float: left; } @media (min-width: 768px) { .col-sm-1-5 { width: 20%; float: left; } } @media (min-width: 992px) { .col-md-1-5 { width: 20%; float: left; } } @media (min-width: 1200px) { .col-lg-1-5 { width: 20%; float: left; } } </style> <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script> <body> <div> <div> <div> <div class="items text-center"> <img src="../img/my.jpg" /> <div> <div id="">姓名:<span>王婷</span></div> </div> <div> <div id="">性别:<span>女</span></div> </div> <div> <div id="">部门:<span>宣传部</span></div> </div> </div> </div> <div> <div class="items text-center"> <img src="../img/my.jpg" /> <div> <div id="">姓名:<span>王婷</span></div> </div> <div> <div id="">性别:<span>女</span></div> </div> <div> <div id="">部门:<span>宣传部</span></div> </div> </div> </div> <div> <div class="items text-center"> <img src="../img/my.jpg" /> <div> <div id="">姓名:<span>王婷</span></div> </div> <div> <div id="">性别:<span>女</span></div> </div> <div> <div id="">部门:<span>宣传部</span></div> </div> </div> </div> <div> <div class="items text-center"> <img src="../img/my.jpg" /> <div> <div id="">姓名:<span>王婷</span></div> </div> <div> <div id="">性别:<span>女</span></div> </div> <div> <div id="">部门:<span>宣传部</span></div> </div> </div> </div> <div> <div class="items text-center"> <img src="../img/my.jpg" /> <div> <div id="">姓名:<span>王婷</span></div> </div> <div> <div id="">性别:<span>女</span></div> </div> <div> <div id="">部门:<span>宣传部</span></div> </div> </div> </div> </div> </div> </body> </html>
以上是bootstrap五列佈局怎麼寫的詳細內容。更多資訊請關注PHP中文網其他相關文章!