oghere
Bootstrap na-agụnye akụkụ dị iche iche na-anabata mkpirisi, padding, na klaasị mmekọ gap iji gbanwee ọdịdị ihe.
Oke na padding
Kenye anabata-enyi na enyi margin
ma ọ bụ padding
ụkpụrụ na mmewere ma ọ bụ akụkụ nke akụkụ ya nwere klaasị mkpirisi. Gụnyere nkwado maka akụrụngwa onye ọ bụla, akụrụngwa niile, yana ihe kwụ ọtọ na kwụ ọtọ. Ewubere klaasị site na maapụ Sass ndabara sitere na .25rem
ruo 3rem
.
Nkọwapụta
Ngwa ime oghere na-emetụta ebe nkwụsịtụ niile, site xs
na ruo xxl
, enweghị mbiri ntụpọ nkwụsịtụ n'ime ha. Nke a bụ n'ihi na a na-etinye klaasị ndị ahụ site min-width: 0
na elu, yabụ na ajụjụ mgbasa ozi ejighị ya. Otú ọ dị, ebe nkwụsịtụ fọdụrụ na-agụnye mbiri nkebi nkwụsịtụ.
A na-akpọ klaasị ahụ site na iji usoro {property}{sides}-{size}
maka xs
na {property}{sides}-{breakpoint}-{size}
maka sm
, md
, lg
, xl
, na xxl
.
Ebe ihe onwunwe bụ otu n'ime:
m
- maka klaasị nke setịpụrụmargin
p
- maka klaasị nke setịpụrụpadding
Ebe akụkụ bụ otu n'ime:
t
- maka klaasị na setịpụrụmargin-top
ma ọ bụpadding-top
b
- maka klaasị na setịpụrụmargin-bottom
ma ọ bụpadding-bottom
s
- (malite) maka klaasị setịpụrụmargin-left
ma ọ bụpadding-left
na LTR,margin-right
ma ọ bụpadding-right
na RTLe
- (njedebe) maka klaasị setịpụrụmargin-right
ma ọ bụpadding-right
na LTR,margin-left
ma ọ bụpadding-left
na RTLx
- maka klaasị nke setịpụrụ ma*-left
na*-right
y
- maka klaasị nke setịpụrụ ma*-top
na*-bottom
- oghere - maka klaasị setịpụrụ
margin
ma ọ bụpadding
n'akụkụ 4 niile nke mmewere
Ebe nha bụ otu n'ime:
0
- maka klaasị na-ewepụmargin
ma ọ bụpadding
site na ịtọ ya0
1
- (site na ndabara) maka klaasị na-edozimargin
ma ọ bụpadding
ka$spacer * .25
2
- (site na ndabara) maka klaasị na-edozimargin
ma ọ bụpadding
ka$spacer * .5
3
- (site na ndabara) maka klaasị na-edozimargin
ma ọ bụpadding
ka$spacer
4
- (site na ndabara) maka klaasị na-edozimargin
ma ọ bụpadding
ka$spacer * 1.5
5
- (site na ndabara) maka klaasị na-edozimargin
ma ọ bụpadding
ka$spacer * 3
auto
- maka klaasị na-ememargin
ka akpaaka
(Ị nwere ike ịgbakwunye nha ndị ọzọ site na ịgbakwunye ndenye na $spacers
mgbanwe maapụ Sass.)
Ihe atụ
Nke a bụ ọmụmaatụ ụfọdụ ihe atụ nke klaasị ndị a:
.mt-0 {
margin-top: 0 !important;
}
.ms-1 {
margin-left: ($spacer * .25) !important;
}
.px-2 {
padding-left: ($spacer * .5) !important;
padding-right: ($spacer * .5) !important;
}
.p-3 {
padding: $spacer !important;
}
N'etiti kwụ ọtọ
Na mgbakwunye, Bootstrap gụnyekwara .mx-auto
klaasị maka ọdịnaya ọkwa mgbochi obosara kwụ n'ahịrị—ya bụ, ọdịnaya nwere display: block
yana width
ntọala—site n'itinye oke ala ka ọ bụrụ auto
.
<div class="mx-auto" style="width: 200px;">
Centered element
</div>
Oke adịghị mma
Na CSS, margin
akụrụngwa nwere ike iji ụkpụrụ ọjọọ ( padding
enweghị ike). Akwụsịghị oke oke ndị a na ndabara , mana enwere ike ịme ya na Sass site na ịtọ ntọala $enable-negative-margins: true
.
Syntax ahụ fọrọ nke nta ka ọ bụrụ otu ihe ndabara, akụrụngwa oke oke dị mma, mana yana mgbakwunye nke n
tupu nha achọrọ. Nke a bụ klas ihe atụ nke na-emegide ya .mt-1
:
.mt-n1 {
margin-top: -0.25rem !important;
}
Oghere
Mgbe ị na-eji display: grid
, ị nwere ike iji gap
akụrụngwa na akpa grid nne na nna. Nke a nwere ike ichekwa na ịnwe ịgbakwunye akụrụngwa oke n'ihe ngwa ngwa (ụmụ nke display: grid
akpa). Ngwa ndị nwere oghere na-anabata ya na ndabara, ma na-ebute ya site na ngwa API anyị, dabere na $spacers
maapụ Sass.
<div class="d-grid gap-3">
<div class="p-2 bg-light border">Grid item 1</div>
<div class="p-2 bg-light border">Grid item 2</div>
<div class="p-2 bg-light border">Grid item 3</div>
</div>
Nkwado gụnyere nhọrọ anabatara maka ebe nkwụsịtụ grid Bootstrap, yana nha isii sitere na $spacers
maapụ ( 0
- 5
). Enweghị .gap-auto
klaasị ịba uru dịka ọ na-arụ ọrụ nke ọma yana .gap-0
.
Sass
Maapụ
A na-ekwupụta ngwa ọrụ spacing site na maapụ Sass wee jiri API ngwa anyị mepụta ya.
$spacer: 1rem;
$spacers: (
0: 0,
1: $spacer * .25,
2: $spacer * .5,
3: $spacer,
4: $spacer * 1.5,
5: $spacer * 3,
);
Utilities API
Ekwuwapụtara akụrụngwa ohere ohere na API ngwa anyị na scss/_utilities.scss
. Mụta otu esi eji ngwa API.
"margin": (
responsive: true,
property: margin,
class: m,
values: map-merge($spacers, (auto: auto))
),
"margin-x": (
responsive: true,
property: margin-right margin-left,
class: mx,
values: map-merge($spacers, (auto: auto))
),
"margin-y": (
responsive: true,
property: margin-top margin-bottom,
class: my,
values: map-merge($spacers, (auto: auto))
),
"margin-top": (
responsive: true,
property: margin-top,
class: mt,
values: map-merge($spacers, (auto: auto))
),
"margin-end": (
responsive: true,
property: margin-right,
class: me,
values: map-merge($spacers, (auto: auto))
),
"margin-bottom": (
responsive: true,
property: margin-bottom,
class: mb,
values: map-merge($spacers, (auto: auto))
),
"margin-start": (
responsive: true,
property: margin-left,
class: ms,
values: map-merge($spacers, (auto: auto))
),
// Negative margin utilities
"negative-margin": (
responsive: true,
property: margin,
class: m,
values: $negative-spacers
),
"negative-margin-x": (
responsive: true,
property: margin-right margin-left,
class: mx,
values: $negative-spacers
),
"negative-margin-y": (
responsive: true,
property: margin-top margin-bottom,
class: my,
values: $negative-spacers
),
"negative-margin-top": (
responsive: true,
property: margin-top,
class: mt,
values: $negative-spacers
),
"negative-margin-end": (
responsive: true,
property: margin-right,
class: me,
values: $negative-spacers
),
"negative-margin-bottom": (
responsive: true,
property: margin-bottom,
class: mb,
values: $negative-spacers
),
"negative-margin-start": (
responsive: true,
property: margin-left,
class: ms,
values: $negative-spacers
),
// Padding utilities
"padding": (
responsive: true,
property: padding,
class: p,
values: $spacers
),
"padding-x": (
responsive: true,
property: padding-right padding-left,
class: px,
values: $spacers
),
"padding-y": (
responsive: true,
property: padding-top padding-bottom,
class: py,
values: $spacers
),
"padding-top": (
responsive: true,
property: padding-top,
class: pt,
values: $spacers
),
"padding-end": (
responsive: true,
property: padding-right,
class: pe,
values: $spacers
),
"padding-bottom": (
responsive: true,
property: padding-bottom,
class: pb,
values: $spacers
),
"padding-start": (
responsive: true,
property: padding-left,
class: ps,
values: $spacers
),
// Gap utility
"gap": (
responsive: true,
property: gap,
class: gap,
values: $spacers
),