Isikhala
I-Bootstrap ifaka phakathi uhla olubanzi lwemajini esabelayo yesandla esifushane kanye namakilasi ensiza ye-padding ukuze kulungiswe ukubukeka kwento.
Isebenza kanjani
Nikeza ukusabela okunobungane margin
noma padding
amanani kusici noma isethi engaphansi yezinhlangothi zayo ezinezigaba ezimfishane. Kufaka phakathi ukusekelwa kwezakhiwo ezingazodwana, zonke izakhiwo, kanye nezakhiwo eziqondile nezivundlile. Amakilasi akhiwe kusuka kumephu ye-Sass ezenzakalelayo ukusuka .25rem
ku- 3rem
.
Isaziso
Izinsiza zokubeka izikhala ezisebenza kuwo wonke ama-breakpoint, ukusuka xs
kuye ukuya ku- xl
, azinaso isifinyezo se-breakpoint kuzo. Lokhu kungenxa yokuthi lawo makilasi asetshenziswa ukusuka min-width: 0
naphezulu, futhi ngaleyo ndlela awaboshiwe umbuzo wemidiya. Ama-breakpoint asele, nokho, afaka isifinyezo se-breakpoint.
Amakilasi aqanjwe kusetshenziswa ifomethi {property}{sides}-{size}
yokuthi xs
, , , kanye .{property}{sides}-{breakpoint}-{size}
sm
md
lg
xl
Lapho impahla ingenye ye:
m
- amakilasi asethiwemargin
p
- amakilasi asethiwepadding
Lapho izinhlangothi zingenye yalezi:
t
- amakilasi abekamargin-top
nomapadding-top
b
- amakilasi abekamargin-bottom
nomapadding-bottom
l
- amakilasi abekamargin-left
nomapadding-left
r
- amakilasi abekamargin-right
nomapadding-right
x
- amakilasi asetha kokubili*-left
futhi*-right
y
- amakilasi asetha kokubili*-top
futhi*-bottom
- blank - amakilasi asetha i-a
margin
nomapadding
kuzo zonke izinhlangothi ezi-4 zesici
Lapho usayizi ungomunye walokhu:
0
- amakilasi asusamargin
nomapadding
ngokuyibeka kuwo0
1
- (ngokuzenzakalelayo) kumakilasi asetha i-margin
nomapadding
ku$spacer * .25
2
- (ngokuzenzakalelayo) kumakilasi asetha i-margin
nomapadding
ku$spacer * .5
3
- (ngokuzenzakalelayo) kumakilasi asetha i-margin
nomapadding
ku$spacer
4
- (ngokuzenzakalelayo) kumakilasi asetha i-margin
nomapadding
ku$spacer * 1.5
5
- (ngokuzenzakalelayo) kumakilasi asetha i-margin
nomapadding
ku$spacer * 3
auto
- kumakilasi asetha okuthimargin
okuzenzakalelayo
(Ungangeza osayizi abengeziwe ngokungeza okufakiwe $spacers
kokuhluka kwemephu ye-Sass.)
Izibonelo
Nazi ezinye izibonelo ezimele lawa makilasi:
.mt-0 {
margin-top: 0 !important;
}
.ml-1 {
margin-left: ($spacer * .25) !important;
}
.px-2 {
padding-left: ($spacer * .5) !important;
padding-right: ($spacer * .5) !important;
}
.p-3 {
padding: $spacer !important;
}
I-Horizontal centering
Ukwengeza, i-Bootstrap iphinde ihlanganise .mx-auto
nekilasi lokumisa phakathi nendawo okuqukethwe kwezinga lebhulokhi enobubanzi obungashintshi—okungukuthi, okuqukethwe okunayo display: block
kanye width
nesethi—ngokusetha amamajini avundlile ukuze auto
.
<div class="mx-auto" style="width: 200px;">
Centered element
</div>
Imajini enegethivu
Ku-CSS, margin
izakhiwo zingasebenzisa amanani angalungile ( padding
angeke). Kusukela ngo-4.2, sengeze izinsiza zemajini ezinegethivu kuwo wonke usayizi wezinombolo ezingewona uziro osohlwini olungenhla (isb, 1
, 2
, 3
, 4
, 5
). Lezi zinsiza zilungele ukwenza ngendlela oyifisayo ama-gutter ekholomu yegridi kuwo wonke ama-breakpoint.
I-syntax icishe ifane nokuzenzakalelayo, izinsiza zemajini ephozithivu, kodwa ngokwengezwa n
kwangaphambi kosayizi oceliwe. Nasi ikilasi lesibonelo eliphambene ne- .mt-1
:
.mt-n1 {
margin-top: -0.25rem !important;
}
Nasi isibonelo sokwenza ngendlela oyifisayo igridi ye-Bootstrap endaweni yokuphumula emaphakathi ( md
) nangaphezulu. Sikhuphule i- .col
padding nge .px-md-5
bese siphikisana nalokho .mx-md-n5
ngomzali .row
.
<div class="row mx-md-n5">
<div class="col px-md-5"><div class="p-3 border bg-light">Custom column padding</div></div>
<div class="col px-md-5"><div class="p-3 border bg-light">Custom column padding</div></div>
</div>