列布局(Columns)

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

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

      工作原理

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

      • 在構(gòu)建網(wǎng)格布局時,所有內(nèi)容都列在列中。 Bootstrap程序網(wǎng)格的層次結(jié)構(gòu)從容器到行到列再到內(nèi)容。在極少數(shù)情況下,您可能會將內(nèi)容和專欄結(jié)合起來,但要注意,可能會產(chǎn)生意想不到的后果。

      • Bootstrap包括預(yù)定義的類,用于創(chuàng)建快速、響應(yīng)的布局。 每個網(wǎng)格層有六個斷點和十幾列,我們已經(jīng)為您構(gòu)建了幾十個類來創(chuàng)建所需的布局。如果您愿意,可以通過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>

      列換行

      如果一行中放置的列數(shù)超過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來完成的,但不是每個實現(xiàn)方法都能解釋這一點。

      .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>

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

      .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-類控制內(nèi)容的視覺順序。這些類是響應(yīng)的,因此您可以按斷點設(shè)置順序(例如,.order-1.order-md-2)。包括對所有六個網(wǎng)格層的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>

      還有響應(yīng)的.order-first.order-last類,它們分別通過應(yīng)用order: -1order: 6來更改元素的順序。這些類也可以根據(jù)需要與編號的.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>

      列偏移

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

      偏移類

      使用.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>

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

      .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外部使用,為元素提供特定的寬度。當(dāng)列類用作行的非直接子級時,將忽略填充。

      .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>

      這些類可以與實用程序一起使用來創(chuàng)建響應(yīng)的浮動圖像。如果文本較短,請確保將內(nèi)容包裝在.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>
      返回頂部
      主站蜘蛛池模板: 一区国严二区亚洲三区| 亚洲av无码不卡一区二区三区| 国产一区二区电影| 国产SUV精品一区二区四| 国产一区视频在线| 久久国产精品免费一区| 国产裸体舞一区二区三区| 亚欧免费视频一区二区三区| 久久影院亚洲一区| 国产精品男男视频一区二区三区| 成人国产精品一区二区网站公司 | 亚洲一区二区高清| 极品少妇一区二区三区四区| 亚洲av无码一区二区三区在线播放| 中文字幕日韩人妻不卡一区| 人妻体内射精一区二区| 高清在线一区二区| 久久国产三级无码一区二区| 国产成人精品无人区一区| 蜜桃视频一区二区三区| 视频一区二区中文字幕| 亚洲一区二区高清| 中文字幕在线观看一区二区| 日本大香伊一区二区三区| 国产在线精品一区二区三区直播| 午夜精品一区二区三区在线观看| 无码AV动漫精品一区二区免费| 视频一区视频二区在线观看| jazzjazz国产精品一区二区| 国产精品自在拍一区二区不卡| 丝袜人妻一区二区三区网站| 国产亚洲福利精品一区| 日韩精品无码免费一区二区三区| 精品无码一区二区三区爱欲| 久久毛片一区二区| 国产在线观看91精品一区| 亚洲成av人片一区二区三区 | 立川理惠在线播放一区| 日韩精品一区二区午夜成人版| 国产精品亚洲不卡一区二区三区| 一本大道东京热无码一区|