列布局(Columns)

      借助我們的彈性盒子網格系統,了解如何使用一些用于對齊、排序和偏移的選項來修改列。另外,請參閱如何使用列類來管理非網格元素的寬度。

      注意! 在深入了解如何修改和自定義網格列之前,請務必先閱讀網格頁。

      工作原理

      • 列構建在網格的彈性盒子體系結構上。 彈性盒子意味著我們可以在行級別更改單個列和修改列組。您可以選擇列的增長、收縮或其他更改方式。

      • 在構建網格布局時,所有內容都列在列中。 Bootstrap程序網格的層次結構從容器到行到列再到內容。在極少數情況下,您可能會將內容和專欄結合起來,但要注意,可能會產生意想不到的后果。

      • Bootstrap包括預定義的類,用于創建快速、響應的布局。 每個網格層有六個斷點和十幾列,我們已經為您構建了幾十個類來創建所需的布局。如果您愿意,可以通過Sass禁用此功能。

      對齊

      使用flexbox對齊實用程序垂直和水平對齊列。

      垂直對齊

      One of three columns
      One of three columns
      One of three columns
      One of three columns
      One of three columns
      One of three columns
      One of three columns
      One of three columns
      One of three columns
      <div class="container">
      <div class="row align-items-start">
      <div class="col">
      One of three columns
      </div>
      <div class="col">
      One of three columns
      </div>
      <div class="col">
      One of three columns
      </div>
      </div>
      <div class="row align-items-center">
      <div class="col">
      One of three columns
      </div>
      <div class="col">
      One of three columns
      </div>
      <div class="col">
      One of three columns
      </div>
      </div>
      <div class="row align-items-end">
      <div class="col">
      One of three columns
      </div>
      <div class="col">
      One of three columns
      </div>
      <div class="col">
      One of three columns
      </div>
      </div>
      </div>
      One of three columns
      One of three columns
      One of three columns
      <div class="container">
      <div class="row">
      <div class="col align-self-start">
      One of three columns
      </div>
      <div class="col align-self-center">
      One of three columns
      </div>
      <div class="col align-self-end">
      One of three columns
      </div>
      </div>
      </div>

      水平對齊

      One of two columns
      One of two columns
      One of two columns
      One of two columns
      One of two columns
      One of two columns
      One of two columns
      One of two columns
      One of two columns
      One of two columns
      One of two columns
      One of two columns
      <div class="container">
      <div class="row justify-content-start">
      <div class="col-4">
      One of two columns
      </div>
      <div class="col-4">
      One of two columns
      </div>
      </div>
      <div class="row justify-content-center">
      <div class="col-4">
      One of two columns
      </div>
      <div class="col-4">
      One of two columns
      </div>
      </div>
      <div class="row justify-content-end">
      <div class="col-4">
      One of two columns
      </div>
      <div class="col-4">
      One of two columns
      </div>
      </div>
      <div class="row justify-content-around">
      <div class="col-4">
      One of two columns
      </div>
      <div class="col-4">
      One of two columns
      </div>
      </div>
      <div class="row justify-content-between">
      <div class="col-4">
      One of two columns
      </div>
      <div class="col-4">
      One of two columns
      </div>
      </div>
      <div class="row justify-content-evenly">
      <div class="col-4">
      One of two columns
      </div>
      <div class="col-4">
      One of two columns
      </div>
      </div>
      </div>

      列換行

      如果一行中放置的列數超過12列,則每組額外列將作為一個單元換行。

      .col-9
      .col-4
      Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.
      .col-6
      Subsequent columns continue along the new line.
      <div class="container">
      <div class="row">
      <div class="col-9">.col-9</div>
      <div class="col-4">.col-4<br>Since 9 + 4 = 13 &gt; 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.</div>
      <div class="col-6">.col-6<br>Subsequent columns continue along the new line.</div>
      </div>
      </div>

      列拆分

      在flexbox中將列拆分為新行需要一個小技巧:添加一個寬度為100%的元素,無論您想在哪里將列換到新行。通常這是通過多個.row來完成的,但不是每個實現方法都能解釋這一點。

      .col-6 .col-sm-3
      .col-6 .col-sm-3
      .col-6 .col-sm-3
      .col-6 .col-sm-3
      <div class="container">
      <div class="row">
      <div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
      <div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
      
      <!-- Force next columns to break to new line -->
      <div class="w-100"></div>
      
      <div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
      <div class="col-6 col-sm-3">.col-6 .col-sm-3</div>
      </div>
      </div>

      您也可以使用我們的響應顯示實用程序在特定斷點處應用此中斷。

      .col-6 .col-sm-4
      .col-6 .col-sm-4
      .col-6 .col-sm-4
      .col-6 .col-sm-4
      <div class="container">
      <div class="row">
      <div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
      <div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
      
      <!-- Force next columns to break to new line at md breakpoint and up -->
      <div class="w-100 d-none d-md-block"></div>
      
      <div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
      <div class="col-6 col-sm-4">.col-6 .col-sm-4</div>
      </div>
      </div>

      重新排序

      排序類

      使用.order-類控制內容的視覺順序。這些類是響應的,因此您可以按斷點設置順序(例如,.order-1.order-md-2)。包括對所有六個網格層的1到5的支持。

      First in DOM, no order applied
      Second in DOM, with a larger order
      Third in DOM, with an order of 1
      <div class="container">
      <div class="row">
      <div class="col">
      First in DOM, no order applied
      </div>
      <div class="col order-5">
      Second in DOM, with a larger order
      </div>
      <div class="col order-1">
      Third in DOM, with an order of 1
      </div>
      </div>
      </div>

      還有響應的.order-first.order-last類,它們分別通過應用order: -1order: 6來更改元素的順序。這些類也可以根據需要與編號的.order-*類混合使用。

      First in DOM, ordered last
      Second in DOM, unordered
      Third in DOM, ordered first
      <div class="container">
      <div class="row">
      <div class="col order-last">
      First in DOM, ordered last
      </div>
      <div class="col">
      Second in DOM, unordered
      </div>
      <div class="col order-first">
      Third in DOM, ordered first
      </div>
      </div>
      </div>

      列偏移

      您可以通過兩種方式偏移網格列:我們的響應式.offset-類和margin實用程序。網格類的大小與列匹配,而邊距對于偏移寬度可變的快速布局更有用。

      偏移類

      使用.offset-md-*類向右移動列。這些類將列的左邊距增加*列。例如,.offset-md-4在四列上移動.col-md-4

      .col-md-4
      .col-md-4 .offset-md-4
      .col-md-3 .offset-md-3
      .col-md-3 .offset-md-3
      .col-md-6 .offset-md-3
      <div class="container">
      <div class="row">
      <div class="col-md-4">.col-md-4</div>
      <div class="col-md-4 offset-md-4">.col-md-4 .offset-md-4</div>
      </div>
      <div class="row">
      <div class="col-md-3 offset-md-3">.col-md-3 .offset-md-3</div>
      <div class="col-md-3 offset-md-3">.col-md-3 .offset-md-3</div>
      </div>
      <div class="row">
      <div class="col-md-6 offset-md-3">.col-md-6 .offset-md-3</div>
      </div>
      </div>

      除了在響應斷點處清除列之外,還可能需要重置偏移量。在網格示例中可以看到這一點。

      .col-sm-5 .col-md-6
      .col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0
      .col-sm-6 .col-md-5 .col-lg-6
      .col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0
      <div class="container">
      <div class="row">
      <div class="col-sm-5 col-md-6">.col-sm-5 .col-md-6</div>
      <div class="col-sm-5 offset-sm-2 col-md-6 offset-md-0">.col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0</div>
      </div>
      <div class="row">
      <div class="col-sm-6 col-md-5 col-lg-6">.col-sm-6 .col-md-5 .col-lg-6</div>
      <div class="col-sm-6 col-md-5 offset-md-2 col-lg-6 offset-lg-0">.col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0</div>
      </div>
      </div>

      外邊距實用類

      通過在v4中遷移到flexbox,您可以使用諸如.me auto之類的邊距實用程序強制同級列彼此分離。

      .col-md-4
      .col-md-4 .ms-auto
      .col-md-3 .ms-md-auto
      .col-md-3 .ms-md-auto
      .col-auto .me-auto
      .col-auto
      <div class="container">
      <div class="row">
      <div class="col-md-4">.col-md-4</div>
      <div class="col-md-4 ms-auto">.col-md-4 .ms-auto</div>
      </div>
      <div class="row">
      <div class="col-md-3 ms-md-auto">.col-md-3 .ms-md-auto</div>
      <div class="col-md-3 ms-md-auto">.col-md-3 .ms-md-auto</div>
      </div>
      <div class="row">
      <div class="col-auto me-auto">.col-auto .me-auto</div>
      <div class="col-auto">.col-auto</div>
      </div>
      </div>

      獨立列類

      .col-*類也可以在 .row外部使用,為元素提供特定的寬度。當列類用作行的非直接子級時,將忽略填充。

      .col-3: width of 25%
      .col-sm-9: width of 75% above sm breakpoint
      <div class="col-3 bg-light p-3 border">
      .col-3: width of 25%
      </div>
      <div class="col-sm-9 bg-light p-3 border">
      .col-sm-9: width of 75% above sm breakpoint
      </div>

      這些類可以與實用程序一起使用來創建響應的浮動圖像。如果文本較短,請確保將內容包裝在.clearfix包裝器中以清除浮動。

      Placeholder Responsive floated image

      A paragraph of placeholder text. We're using it here to show the use of the clearfix class. We're adding quite a few meaningless phrases here to demonstrate how the columns interact here with the floated image.

      As you can see the paragraphs gracefully wrap around the floated image. Now imagine how this would look with some actual content in here, rather than just this boring placeholder text that goes on and on, but actually conveys no tangible information at. It simply takes up space and should not really be read.

      And yet, here you are, still persevering in reading this placeholder text, hoping for some more insights, or some hidden easter egg of content. A joke, perhaps. Unfortunately, there's none of that here.

      <div class="clearfix">
      <img src="..." class="col-md-6 float-md-end mb-3 ms-md-3" alt="...">
      
      <p>
      A paragraph of placeholder text. We're using it here to show the use of the clearfix class. We're adding quite a few meaningless phrases here to demonstrate how the columns interact here with the floated image.
      </p>
      
      <p>
      As you can see the paragraphs gracefully wrap around the floated image. Now imagine how this would look with some actual content in here, rather than just this boring placeholder text that goes on and on, but actually conveys no tangible information at. It simply takes up space and should not really be read.
      </p>
      
      <p>
      And yet, here you are, still persevering in reading this placeholder text, hoping for some more insights, or some hidden easter egg of content. A joke, perhaps. Unfortunately, there's none of that here.
      </p>
      </div>
      返回頂部
      主站蜘蛛池模板: 99精品国产高清一区二区三区| 国产综合一区二区在线观看| 秋霞鲁丝片一区二区三区| 人妻无码一区二区三区四区| 日韩精品视频一区二区三区| 国产一区二区三区免费观在线| 精品一区狼人国产在线| 亚洲爽爽一区二区三区| 一区一区三区产品乱码| 国产a∨精品一区二区三区不卡| 无码人妻久久一区二区三区蜜桃| 精品无码一区二区三区爱欲九九| 精品国产高清自在线一区二区三区| 国产日本一区二区三区| 亚洲Av无码一区二区二三区| 亚洲国产综合精品一区在线播放| 日韩一区二区久久久久久| 久久国产午夜一区二区福利 | 精品一区精品二区制服| 精品无码人妻一区二区三区| 亚洲午夜精品一区二区公牛电影院| 91在线一区二区| 91一区二区三区| 视频一区二区在线播放| 国产精品女同一区二区| 一区二区免费视频| 九九久久99综合一区二区| 免费萌白酱国产一区二区三区 | 色老头在线一区二区三区| 国产探花在线精品一区二区| 国产一区二区女内射| 无码aⅴ精品一区二区三区浪潮| 日韩精品一区二区亚洲AV观看| 精品福利一区二区三| 亚洲一区二区三区亚瑟| 亚洲av色香蕉一区二区三区蜜桃| 波多野结衣AV一区二区三区中文| 国产高清视频一区二区| 国产乱码精品一区二区三| 国99精品无码一区二区三区| 中文字幕在线不卡一区二区|