Ku hambanisiwa ka swilo
Bootstrap yi katsa nxaxamelo wo anama wa titlilasi ta vukorhokeri bya margin lebyi hlamulaka hi shorthand na padding ku cinca xivumbeko xa elemente.
Ndlela leyi swi tirhaka ha yona
Avela responsive-friendly margin
kumbe padding
values eka element kumbe subset ya matlhelo ya yona na titlilasi ta shorthand. Ku katsa na nseketelo wa swihlawulekisi swa munhu hi xiyexe, swihlawulekisi hinkwaswo, na swihlawulekisi leswi yimisiweke na leswi nga etlhelo. Titlilasi ti akiwile ku suka eka mepe wa Sass wa ntolovelo ku sukela eka .25rem
ku ya eka 3rem
.
Notation
Switirhisiwa swa ku hambanyisa leswi tirhaka eka tindhawu hinkwato to wisa, ku suka eka xs
ku ya eka xl
, a swi na xifunengeto xa swiphemu swo tsema eka swona. Leswi swi vangiwa hikuva titlilasi teto ti tirhisiwa ku suka min-width: 0
na le henhla, naswona xisweswo a ti bohiwi hi xivutiso xa vuhangalasi bya mahungu. Hambiswiritano, swiphemu leswi saleke swa ku tshoveka swi katsa xifunengeto xa ku tshoveka.
Titlilasi ti thyiwile mavito hi ku tirhisa xivumbeko {property}{sides}-{size}
xa xs
na {property}{sides}-{breakpoint}-{size}
xa sm
, md
, lg
, na xl
.
Laha nhundzu yi nga yin’wana ya:
m
- ya titlilasi leti vekakamargin
p
- ya titlilasi leti vekakapadding
Laha matlhelo ku nga rin’wana ra:
t
- ya titlilasi leti vekakamargin-top
kumbepadding-top
b
- ya titlilasi leti vekakamargin-bottom
kumbepadding-bottom
l
- ya titlilasi leti vekakamargin-left
kumbepadding-left
r
- ya titlilasi leti vekakamargin-right
kumbepadding-right
x
- eka titlilasi leti vekaka havumbirhi bya swona*-left
na*-right
y
- eka titlilasi leti vekaka havumbirhi bya swona*-top
na*-bottom
- blank - ya titlilasi leti vekaka a
margin
kumbepadding
eka matlhelo hinkwawo ya 4 ya elemente
Laha sayizi yi nga yin’wana ya:
0
- eka titlilasi leti herisakamargin
kumbepadding
hi ku yi veka eka0
1
- (hi ku tiyimisela) eka titlilasi leti vekakamargin
kumbepadding
ku$spacer * .25
2
- (hi ku tiyimisela) eka titlilasi leti vekakamargin
kumbepadding
ku$spacer * .5
3
- (hi ku tiyimisela) eka titlilasi leti vekakamargin
kumbepadding
ku$spacer
4
- (hi ku tiyimisela) eka titlilasi leti vekakamargin
kumbepadding
ku$spacer * 1.5
5
- (hi ku tiyimisela) eka titlilasi leti vekakamargin
kumbepadding
ku$spacer * 3
auto
- ya titlilasi leti vekakamargin
ku auto
(U nga engetela vukulu byin’wana hi ku engetela swilo leswi nghenisiweke eka $spacers
xihlawulekisi xa mepe wa Sass.)
Swikombiso
Hi leswi swikombiso swin’wana leswi yimelaka titlilasi leti:
.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;
}
Ku vekiwa exikarhi ka horizontal
Additionally, Bootstrap also includes an .mx-auto
class for horizontally centering fixed-width block level content—that is, content that has display: block
and a width
set—by setting the horizontal margins to auto
.
<div class="mx-auto" style="width: 200px;">
Centered element
</div>
Negative margin
In CSS, margin
properties can utilize negative values (padding
cannot). As of 4.2, we’ve added negative margin utilities for every non-zero integer size listed above (e.g., 1
, 2
, 3
, 4
, 5
). These utilities are ideal for customizing grid column gutters across breakpoints.
The syntax is nearly the same as the default, positive margin utilities, but with the addition of n
before the requested size. Here’s an example class that’s the opposite of .mt-1
:
.mt-n1 {
margin-top: -0.25rem !important;
}
Hi lexi xikombiso xa ku lulamisa giridi ya Bootstrap eka ndhawu yo md
wisa ya le xikarhi ( ) na le henhla. Hi engetele .col
padding hi .px-md-5
ivi hi counteract sweswo hi .mx-md-n5
on the 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>