Spaysin we de bitwin dɛn
Bootstrap inklud wan big renj ɔf shɔthand rispɔnsiv margin ɛn padding yutiliti klas fɔ modify wan ɛlimɛnt in apinɛns.
Aw i de wok
Asayn rispɔnsiv-frenli margin
ɔ padding
valyu to wan ɛlimɛnt ɔ wan sɔbsɛt fɔ in sayd dɛn wit shɔthand klas dɛn. Inklud sɔpɔt fɔ wan wan prɔpati dɛn, ɔl di prɔpati dɛn, ɛn vertikal ɛn ɔrizɔntal prɔpati dɛn. Dɛn bil klas dɛn frɔm wan difɔlt Sass map we de frɔm .25rem
to 3rem
.
Noteshɔn fɔ di Baybul
Spaysin yutiliti dɛn we de aplay to ɔl di brekpɔynt dɛn, frɔm xs
to xl
, nɔ gɛt brekpɔynt abrɛvieshɔn insay dɛn. Dis na bikɔs dɛn klas dɛn de de aplay frɔm min-width: 0
ɛn ɔp, ɛn so dɛn nɔ de tay dɛn bay wan midia kwɛstyɔn. Bɔt di ɔda brekpoint dɛn gɛt wan brekpoint abrevieshɔn.
Dɛn gi di klas dɛn nem bay we dɛn yuz di fɔmat {property}{sides}-{size}
fɔ xs
ɛn {property}{sides}-{breakpoint}-{size}
fɔ sm
, md
, lg
, ɛn xl
.
Usay prɔpati na wan pan:
m
- fɔ klas dɛn we de sɛtmargin
p
- fɔ klas dɛn we de sɛtpadding
Usay sayd dɛn na wan pan:
t
- fɔ klas dɛn we de sɛtmargin-top
ɔpadding-top
b
- fɔ klas dɛn we de sɛtmargin-bottom
ɔpadding-bottom
l
- fɔ klas dɛn we de sɛtmargin-left
ɔpadding-left
r
- fɔ klas dɛn we de sɛtmargin-right
ɔpadding-right
x
- fɔ klas dɛn we de sɛt ɔl tu*-left
ɛn*-right
y
- fɔ klas dɛn we de sɛt ɔl tu*-top
ɛn*-bottom
- blank - fɔ klas dɛn we de sɛt wan
margin
ɔpadding
na ɔl di 4 say dɛn na di ɛlimɛnt
Usay saiz na wan pan:
0
- fɔ klas dɛn we de pul dimargin
ɔpadding
bay we dɛn sɛt am to0
1
- (bay difɔlt) fɔ klas dɛn we de sɛt dimargin
ɔpadding
to$spacer * .25
2
- (bay difɔlt) fɔ klas dɛn we de sɛt dimargin
ɔpadding
to$spacer * .5
3
- (bay difɔlt) fɔ klas dɛn we de sɛt dimargin
ɔpadding
to$spacer
4
- (bay difɔlt) fɔ klas dɛn we de sɛt dimargin
ɔpadding
to$spacer * 1.5
5
- (bay difɔlt) fɔ klas dɛn we de sɛt dimargin
ɔpadding
to$spacer * 3
auto
- fɔ klas dɛn we de sɛt dimargin
to ɔto
(Yu kin ad mɔ saiz dɛn bay we yu ad ɛntri dɛn to di $spacers
Sass map vɛriɔbul.)
Ɛgzampul dɛn
Na sɔm ɛgzampul dɛn we de sho dɛn klas ya:
.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;
}
Ɔrizɔntal sɛntrin
Apat frɔm dat, Bootstrap gɛt bak wan .mx-auto
klas fɔ ɔrizɔntal sɛntrɛd fiks-wid blɔk lɛvɛl kɔntinyu—dat na, kɔntinyu we gɛt display: block
ɛn wan width
sɛt—bay we yu sɛt di ɔrizɔntal margin dɛn to auto
.
<div class="mx-auto" style="width: 200px;">
Centered element
</div>
Negatif margin fɔ di wan dɛn we de
Insay CSS, margin
prɔpati dɛn kin yuz nɛgitiv valyu dɛn ( padding
nɔ kin ebul). As of 4.2, wi dɔn ad negatif margin yutiliti fɔ ɛvri nɔ-ziro intaj saiz we dɛn list ɔp (ɛgz., 1
, 2
, 3
, 4
, 5
). Dɛn yutiliti ya fayn fɔ kɔstɔmayz grid kɔlɔm gɔta dɛn akɔdin to brekpɔynt dɛn.
Di sɛntaks de nia di sem wit di difɔlt, pɔsitiv margin yutiliti dɛn, bɔt wit di addɛshɔn fɔ n
bifo di saiz we dɛn aks fɔ. Na wan ɛgzampul klas we na di ɔpɔzit fɔ .mt-1
:
.mt-n1 {
margin-top: -0.25rem !important;
}
Na wan ɛgzampul fɔ kɔstɔmayz di Bootstrap grid na di midul ( md
) brekpɔynt ɛn ɔp. Wi don inkrisayz di .col
padding wit .px-md-5
en den counteract dat wit .mx-md-n5
on di parent .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>