Yeqela kokuqukethwe okuyinhloko Yeqela ku-docs navigation
Check
in English

Amakholomu

Funda ukuthi ungawashintsha kanjani amakholomu ngezinketho ezimbalwa zokuqondanisa, uku-oda, nokusetha ngenxa yesistimu yethu yegridi ye-flexbox. Futhi, bona indlela yokusebenzisa amakilasi ekholomu ukuze ulawule ububanzi bezinto ezingezona zegridi.

Amakhanda phezulu! Qiniseka ukuthi ufunda ikhasi Legridi kuqala ngaphambi kokungena kokuthi ungawashintsha kanjani futhi wenze ngendlela oyifisayo amakholomu egridi yakho.

Basebenza kanjani

  • Amakholomu akhela phezu kwesakhiwo se-flexbox yegridi. I-Flexbox isho ukuthi sinezinketho zokushintsha amakholomu ngamanye kanye nokulungisa amaqembu amakholomu ezingeni lomugqa . Uyakhetha ukuthi amakholomu akhula kanjani, ancipha, noma ashintsha kanjani.

  • Lapho wakha izakhiwo zegridi, konke okuqukethwe kuhamba ngamakholomu. Isigaba segridi ye-Bootstrap sisuka kusiqukathi siye kumugqa siye kukholomu siye kokuqukethwe kwakho. Ezikhathini ezingavamile, ungase uhlanganise okuqukethwe nekholomu, kodwa qaphela ukuthi kungase kube nemiphumela engahlosiwe.

  • I-Bootstrap ihlanganisa amakilasi achazwe ngaphambilini okudala izakhiwo ezisheshayo, eziphendulayo. Ngama -breakpoint ayisithupha kanye namakholomu ayishumi nambili esigabeni ngasinye segridi, sinenqwaba yamakilasi asevele akhelwe wena ukuze udale izakhiwo ozifisayo. Lokhu kungakhutshazwa nge-Sass uma uthanda.

Ukuqondanisa

Sebenzisa izinsiza zokuqondanisa kwe-flexbox ukuze uqondanise amakholomu aqondile futhi avundlile.

Ukuqondanisa okuqondile

Enye yamakholomu amathathu
Enye yamakholomu amathathu
Enye yamakholomu amathathu
Enye yamakholomu amathathu
Enye yamakholomu amathathu
Enye yamakholomu amathathu
Enye yamakholomu amathathu
Enye yamakholomu amathathu
Enye yamakholomu amathathu
html
<div class="container text-center">
  <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>
Enye yamakholomu amathathu
Enye yamakholomu amathathu
Enye yamakholomu amathathu
html
<div class="container text-center">
  <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>

Ukuqondanisa okuvundlile

Enye yamakholomu amabili
Enye yamakholomu amabili
Enye yamakholomu amabili
Enye yamakholomu amabili
Enye yamakholomu amabili
Enye yamakholomu amabili
Enye yamakholomu amabili
Enye yamakholomu amabili
Enye yamakholomu amabili
Enye yamakholomu amabili
Enye yamakholomu amabili
Enye yamakholomu amabili
html
<div class="container text-center">
  <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>

Ukugoqa ikholomu

Uma amakholomu angaphezu kuka-12 ebekwe phakathi komugqa owodwa, iqembu ngalinye lamakholomu engeziwe, njengeyunithi eyodwa, lizogoqa emugqeni omusha.

.col-9
.col-4
Kusukela ku-9 + 4 = 13 > 12, le div enamakholomu angu-4 ebanzi igoqwa emugqeni omusha njengeyunithi eyodwa ehlangene.
.col-6
Amakholomu alandelayo ayaqhubeka emugqeni omusha.
html
<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>

Ukuhlukana kwekholomu

Ukuhlephula amakholomu emugqeni omusha ku-flexbox kudinga ukugenca okuncane: engeza i-elementi nanoma width: 100%yikuphi lapho ufuna ukugoqa khona amakholomu akho emugqeni omusha. Imvamisa lokhu kufezwa ngama-multiple .rows, kodwa akuzona zonke izindlela zokuqalisa ezingamela lokhu.

.col-6 .col-sm-3
.col-6 .col-sm-3
.col-6 .col-sm-3
.col-6 .col-sm-3
html
<div class="container text-center">
  <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>

Ungase futhi usebenzise leli khefu ezindaweni ezithile zokunqamuka nezinsiza zethu zokubonisa ezisabelayo .

.col-6 .col-sm-4
.col-6 .col-sm-4
.col-6 .col-sm-4
.col-6 .col-sm-4
html
<div class="container text-center">
  <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>

Ihlela kabusha

Oda amakilasi

Sebenzisa .order-amakilasi ukuze ulawule ukuhleleka okubukwayo kokuqukethwe kwakho. Lawa makilasi ayasabela, ngakho-ke ungasetha i- orderbreakpoint (isb, .order-1.order-md-2). Kufaka usekelo 1kuwo 5wonke amagridi ayisithupha.

Okokuqala ku-DOM, alikho i-oda elifakiwe
Okwesibili ku-DOM, nge-oda elikhudlwana
Okwesithathu ku-DOM, nge-oda elingu-1
html
<div class="container text-center">
  <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>

Kukhona futhi amakilasi aphendulayo .order-firstnamakilasi .order-lastashintsha orderisici ngokufaka order: -1kanye order: 6, ngokulandelana. Lawa makilasi angabuye axutshwe .order-*namakilasi anezinombolo njengoba kudingeka.

Okokuqala ku-DOM, ku-odwe kokugcina
Okwesibili ku-DOM, akuhlelekile
Okwesithathu ku-DOM, ku-odwe kuqala
html
<div class="container text-center">
  <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>

Ukusetha amakholomu

Ungakwazi ukulungisa amakholomu egridi ngezindlela ezimbili: .offset-amakilasi ethu egridi aphendulayo kanye nezinsiza zethu zemajini . Amakilasi egridi alinganiswa ukuze afane namakholomu kuyilapho amamajini ewusizo kakhulu ezakhiweni ezisheshayo lapho ububanzi be-offset buyahlukahluka.

Amakilasi e-offset

Hambisa amakholomu kwesokudla usebenzisa .offset-md-*amakilasi. Lezi zigaba zandisa umkhawulo wesokunxele wekholomu *ngamakholomu. Isibonelo, .offset-md-4ihamba .col-md-4phezu kwamakholomu amane.

.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
html
<div class="container text-center">
  <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>

Ngokungeziwe ekususeni ikholomu ezindaweni ezisabelayo, ungase udinge ukusetha kabusha ama-offset. Bona lokhu kusebenza esibonelweni segridi .

.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
html
<div class="container text-center">
  <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>

Izinsiza ze-margin

Ngokuthuthela ku-flexbox ku-v4, ungasebenzisa izinsiza zemajini njengokuphoqa amakholomu ezelamani ukuthi aqhelelane .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
html
<div class="container text-center">
  <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>

Amakilasi ekholomu ezimele

Amakilasi .col-*angasetshenziswa ngaphandle kwe-a .rowukunikeza isici ububanzi obuthile. Noma kunini lapho amakilasi ekholomu esetshenziswa njengezingane ezingaqondile zomugqa, ama-paddings ayashiywa.

.col-3: ububanzi obungu-25%
.col-sm-9: ububanzi obungu-75% ngaphezu kwendawo yokuphumula ye-sm
html
<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>

Amakilasi angasetshenziswa kanye nezinsiza ukudala izithombe eziphendulayo ezintantayo. Qiniseka ukuthi ukusonga okuqukethwe .clearfixesongeni ukuze usule ukuntanta uma umbhalo umfushane.

Placeholder Responsive floated image

Isigaba sombhalo wesimeli. Siyisebenzisa lapha ukuze sibonise ukusetshenziswa kwekilasi le-clearfix. Sengeza imishwana embalwa engasho lutho lapha ukuze sibonise ukuthi amakholomu asebenzisana kanjani lapha nesithombe esintantayo.

Njengoba ubona izigaba zigoqa kahle isithombe esintanteyo. Manje cabanga ukuthi lokhu kuzobukeka kanjani ngokuqukethwe kwangempela okulapha, kunokuba nje lo mbhalo oyisicefe oqhubeka njalo, kodwa empeleni ongadlulisi ulwazi olubambekayo kuwo. Imane ithatha indawo futhi akufanele ngempela ifundwe.

Kodwa nokho, nakhu, usaphikelela ekufundeni lo mbhalo wesimeli, unethemba lokuthola eminye imininingwane, noma iqanda lephasika elifihliwe lokuqukethwe. Ihlaya, mhlawumbe. Ngeshwa, akukho lokho lapha.

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