Grid and spacing
BS04. 排版系統 Grid system
為了便利使用者設計版面,bootstrap通常以12等分作為切割等寬欄位的基準,並且讓使用者得以利用class來指定他要怎麼切割這12個等寬欄位。
首先要指定一個
<div class="row">之後在其中再建立其他<div>.col-sm-4其中的sm所指的是這個版面要給平板電腦用的,其他的代號包含xsfor phones、mdfor desktops、andlgfor larger desktops。
將一列的版面切割為4:4:4三塊。
將一列的版面切割為4:8兩個不等的區塊。
刻意在左方來作為留白。
若希望在grid排版上能夠左邊空出4,然後只留下右邊8,一來可以用上面那種辦法,先做一個空的.col-sm-4的<div>,再做一個.col-sm-8的<div>。但事實上,如果你始終不會用到左邊那區塊的話,可以用 來製作間隔
參考資料 http://getbootstrap.com/css/
標準寫法:使用offset
BS04.1 Grid system for RWD
See https://getbootstrap.com/docs/4.0/layout/grid/
Bootstrap在3.0與4.5版分別提供四到五個等級的「斷點」,為預設的不同瀏覽器大小,讓程式設計師可以用指派class,就設定好因應不同螢幕大小的排版。一共分為以下五階層。

當程式碼如以下指定,代表我們希望這些元件在不同螢幕大小時有不一樣的表現
以上面的code而言,那螢幕夠大的時候看起來應該是如下圖,目前是照三個.col-md-4來排版。
若是螢幕太小的話,那就會變成按照.col-6來排版,那就是兩個col-6,所以中間那列的元件會排成兩欄如下。
<Practice> #1. 用grid system完成剩下的division
<Practice> #2 Footer
About glyphicon, take a look at http://www.w3schools.com/bootstrap/bootstrap_ref_comp_glyphs.asp
BS04.1 Layout:clearfix
https://getbootstrap.com/docs/4.0/utilities/clearfix/
主要是提供clear:both功能的class。

BS05. Spacing: Margin and Padding
See https://getbootstrap.com/docs/4.0/utilities/spacing/
Examples
https://getbootstrap.com/docs/4.0/utilities/spacing/
Where property is one of:
m- for classes that setmarginp- for classes that setpadding
Where sides is one of:
t- for classes that setmargin-toporpadding-topb- for classes that setmargin-bottomorpadding-bottoml- for classes that setmargin-leftorpadding-leftr- for classes that setmargin-rightorpadding-rightx- for classes that set both*-leftand*-righty- for classes that set both*-topand*-bottomblank - for classes that set a
marginorpaddingon all 4 sides of the element
Where size is one of:
0- for classes that eliminate themarginorpaddingby setting it to01- (by default) for classes that set themarginorpaddingto$spacer * .252- (by default) for classes that set themarginorpaddingto$spacer * .53- (by default) for classes that set themarginorpaddingto$spacer4- (by default) for classes that set themarginorpaddingto$spacer * 1.55- (by default) for classes that set themarginorpaddingto$spacer * 3auto- for classes that set themarginto auto
Last updated
Was this helpful?