Awọn ọwọn
Kọ ẹkọ bi o ṣe le ṣe atunṣe awọn ọwọn pẹlu ọwọ awọn aṣayan fun titete, pipaṣẹ, ati aiṣedeede ọpẹ si eto grid flexbox wa. Pẹlupẹlu, wo bii o ṣe le lo awọn kilasi ọwọn lati ṣakoso awọn iwọn ti awọn eroja ti kii ṣe akoj.
Bawo ni wọn ṣe n ṣiṣẹ
-
Awọn ọwọn kọ lori akoj ká flexbox faaji. Flexbox tumọ si pe a ni awọn aṣayan fun iyipada awọn ọwọn kọọkan ati iyipada awọn ẹgbẹ ti awọn ọwọn ni ipele ila . O yan bi awọn ọwọn ṣe ndagba, dinku, tabi bibẹẹkọ yipada.
-
Nigbati o ba n kọ awọn ipilẹ akoj, gbogbo akoonu lọ ni awọn ọwọn. Awọn logalomomoise ti Bootstrap ká akoj lọ lati eiyan si kana si iwe si akoonu rẹ. Ni awọn iṣẹlẹ to ṣọwọn, o le darapọ akoonu ati iwe, ṣugbọn ṣe akiyesi pe awọn abajade airotẹlẹ le wa.
-
Bootstrap pẹlu awọn kilasi asọye tẹlẹ fun ṣiṣẹda iyara, awọn ipilẹ idahun. Pẹlu awọn aaye fifọ mẹfa ati awọn ọwọn mejila ni ipele akoj kọọkan, a ni dosinni ti awọn kilasi ti a ti kọ tẹlẹ fun ọ lati ṣẹda awọn ipalemo ti o fẹ. Eyi le jẹ alaabo nipasẹ Sass ti o ba fẹ.
Titete
Lo awọn ohun elo titete apoti flexbox lati so awọn ọwọn ni inaro ati petele.
Titete inaro
<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>
<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>
Petele titete
<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>
Fidi ọwọn
Ti o ba ju awọn ọwọn 12 ti a gbe laarin ila kan, ẹgbẹ kọọkan ti awọn ọwọn afikun yoo, bi ẹyọkan, fi ipari si laini tuntun kan.
Lati 9 + 4 = 13> 12, div-jakejado 4-column yii yoo div sori laini titun kan bi ẹyọkan ti o tẹriba.
Awọn ọwọn ti o tẹle tẹsiwaju pẹlu laini tuntun.
<div class="container">
<div class="row">
<div class="col-9">.col-9</div>
<div class="col-4">.col-4<br>Since 9 + 4 = 13 > 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>
Awọn fifọ ọwọn
Pipa awọn ọwọn si laini tuntun ni flexbox nilo gige kekere kan: ṣafikun eroja kan pẹlu width: 100%
nibikibi ti o fẹ lati fi ipari si awọn ọwọn rẹ si laini tuntun kan. Ni deede eyi ni a ṣe pẹlu ọpọlọpọ awọn .row
s, ṣugbọn kii ṣe gbogbo ọna imuse le ṣe akọọlẹ fun eyi.
<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>
O tun le lo isinmi yii ni awọn aaye fifọ ni pato pẹlu awọn ohun elo ifihan idahun wa .
<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>
Atunse
Awọn kilasi ibere
Lo .order-
awọn kilasi fun iṣakoso aṣẹ wiwo akoonu rẹ. Awọn kilasi wọnyi jẹ idahun, nitorinaa o le ṣeto order
nipasẹ aaye fifọ (fun apẹẹrẹ, .order-1.order-md-2
). Pẹlu atilẹyin fun 1
kọja 5
gbogbo awọn ipele akoj mẹfa.
<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>
Awọn idahun tun wa .order-first
ati .order-last
awọn kilasi ti o yi order
ohun elo pada nipa lilo order: -1
ati order: 6
, lẹsẹsẹ. Awọn kilasi wọnyi tun le ni idapọ pẹlu awọn .order-*
kilasi ti o ni nọmba bi o ṣe nilo.
<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>
Awọn ọwọn aiṣedeede
O le ṣe aiṣedeede awọn ọwọn akoj ni awọn ọna meji: awọn .offset-
kilasi grid idahun wa ati awọn ohun elo ala wa . Awọn kilasi akoj jẹ iwọn lati baamu awọn ọwọn lakoko ti awọn ala jẹ iwulo diẹ sii fun awọn ipalemo iyara nibiti iwọn aiṣedeede jẹ oniyipada.
Awọn kilasi aiṣedeede
Gbe awọn ọwọn si ọtun nipa lilo .offset-md-*
awọn kilasi. Awọn kilasi wọnyi ṣe alekun ala osi ti iwe kan nipasẹ *
awọn ọwọn. Fun apẹẹrẹ, .offset-md-4
gbigbe .col-md-4
lori awọn ọwọn mẹrin.
<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>
Ni afikun si imukuro ọwọn ni awọn aaye fifọ idahun, o le nilo lati tun awọn aiṣedeede. Wo eyi ni iṣe ni apẹẹrẹ akoj .
<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>
Awọn ohun elo ala
Pẹlu gbigbe si flexbox ni v4, o le lo awọn ohun elo ala bi .me-auto
lati fi ipa mu awọn ọwọn arakunrin kuro lọdọ ara wọn.
<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>
Standalone iwe kilasi
Awọn .col-*
kilasi tun le ṣee lo ni ita kan .row
lati fun ano ni iwọn kan pato. Nigbakugba ti awọn kilasi iwe ba lo bi awọn ọmọ ti kii ṣe taara ti ọna kan, awọn paddings ni a yọkuro.
<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>
Awọn kilasi le ṣee lo papọ pẹlu awọn ohun elo lati ṣẹda awọn aworan ti o lelefo loju omi. Rii daju pe o fi ipari si akoonu naa sinu iwe .clearfix
ipari lati ko oju omi leefofo kuro ti ọrọ ba kuru.
A ìpínrọ ti placeholder ọrọ. A n lo o nibi lati ṣafihan lilo kilasi clearfix. A n ṣafikun pupọ awọn gbolohun ọrọ ti ko ni itumọ nibi lati ṣe afihan bi awọn ọwọn ṣe n ṣe ajọṣepọ nibi pẹlu aworan ti o leefofo.
Bi o ṣe le rii awọn oju-iwe naa pẹlu oore-ọfẹ yi aworan ti o leefofo. Bayi fojuinu bawo ni eyi yoo ṣe rii pẹlu diẹ ninu akoonu gangan ni ibi, dipo ki o kan ọrọ ibi ibi alaidun yii ti o tẹsiwaju ati siwaju, ṣugbọn nitootọ ko ṣe alaye alaye ojulowo ni. O kan gba aaye ati pe ko yẹ ki o ka ni gaan.
Ati sibẹsibẹ, nibi o wa, tun ni itara ni kika ọrọ ibi-aye yii, nireti fun awọn oye diẹ sii, tabi diẹ ninu awọn ẹyin Ọjọ ajinde Kristi ti o farapamọ ti akoonu. Awada, boya. Laanu, ko si eyi nibi.
<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>