Spacing
Bootstrap amplis comprehendit marginem notae responsionis, padding, et intervallum classes utilitatis ad speciem elementi mutandam.
Margine et Nullam
Responsivo-amico margin
vel padding
valores elementi vel subsessorum laterum cum actuariis notatis assignare. Subsidia includit proprietates singulas, omnes proprietates, et verticales et horizontales. Classes aedificatae sunt ex defalta Sass map ranging ab .25rem
ad 3rem
.
Uti CSS Grid layout moduli? Vide utens gap utilitatem .
Notatio
Utilitas iustae quae ad omnes confractiones applicat, ab xs
to xxl
, nullum in eis abbreviationem habent. Causa est, quia illae classes ex et sursum applicantur min-width: 0
, ideoque interrogatione media non tenentur. Reliquae autem fracturae punctum abbreviationem includunt.
Classes nominantur utens forma {property}{sides}-{size}
pro xs
et {property}{sides}-{breakpoint}-{size}
pro sm
, md
, lg
, xl
et xxl
.
ubi res una est;
m
- for classes, quaemargin
p
- for classes, quaepadding
Ubi laterum unus est;
t
- pro classes, quaemargin-top
oripadding-top
b
- pro classes, quaemargin-bottom
oripadding-bottom
s
- (initium) pro generibus ponemargin-left
autpadding-left
in LTR,margin-right
autpadding-right
in RTLe
- (finem) pro generibus ponemargin-right
autpadding-right
in LTR,margin-left
autpadding-left
in RTL .x
- pro classes, quae tum*-left
et*-right
y
- pro classes, quae tum*-top
et*-bottom
- blank - pro classes, quae a
margin
velpadding
in IV partibus elementi
Ubi magnitudo unius est;
0
- pro classes, quae eliminaremargin
velpadding
excidere0
1
- (per default) pro classes, quae ponemargin
velpadding
to$spacer * .25
2
- (per default) pro classes, quae ponemargin
velpadding
to$spacer * .5
3
- (per default) pro classes, quae ponemargin
velpadding
to$spacer
4
- (per default) pro classes, quae ponemargin
velpadding
to$spacer * 1.5
5
- (per default) pro classes, quae ponemargin
velpadding
to$spacer * 3
auto
- pro classes, quaemargin
ad auto-
(Potes amplius addere quantitates addendo ad $spacers
tabulam Sass variabilis.)
Exempla
Exempla repraesentativa hic sunt horum generum;
.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;
}
Horizontalis centrum
Accedit, Bootstrap etiam .mx-auto
genus includit pro horizontaliter centrum fixum-latum rotundum in plano contento, id est, contentum quod habet display: block
et statutum width
, ponendo ad margines horizontales auto
.
<div class="mx-auto" style="width: 200px;">
Centered element
</div>
Negans margine
In CSS, margin
possessiones valoribus negativis uti possunt ( padding
non possunt). Hae orae negativae per default debiles sunt , sed in Sass ponendo effici possunt $enable-negative-margins: true
.
Syntaxum fere idem est ac utilitatis defectus, margo positivus, sed cum additione n
ante quantitatem petitam. Hic exemplum genus quod oppositum .mt-1
;
.mt-n1 {
margin-top: -0.25rem !important;
}
Gap
Cum usus display: grid
, uti potes gap
in vasis parentis eget. Hoc servare potest, cum utilitates margini addere ad singulas euismod items (filios display: grid
continentis). Hiatus utilitates ex defectu respondentes sunt, et per utilitates nostras API generantur, ex $spacers
tabula 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>
Firmamentum includit optiones responsivas pro omnibus fragmentorum craticularum Bootstrap, necnon sex magnitudinum e $spacers
tabula ( 0
- 5
). Utilitas non est .gap-auto
genus quod idem valet .gap-0
.
Sass
Maps
Utilitas iustae per tabulam Sass declarantur et postea cum nostris utilitatibus API generantur.
$spacer: 1rem;
$spacers: (
0: 0,
1: $spacer * .25,
2: $spacer * .5,
3: $spacer,
4: $spacer * 1.5,
5: $spacer * 3,
);
$negative-spacers: if($enable-negative-margins, negativify-map($spacers), null);
Utilitas API
Utilitas in nostris utilitatibus declaratur spatio API in scss/_utilities.scss
. Utilitatibus uti disce 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
),