Skip to main content Skip ad navigationem soUicitudo
Check
in English

Spacing

Bootstrap amplis comprehendit marginem notae responsionis, padding, et intervallum classes utilitatis ad speciem elementi mutandam.

Margine et Nullam

Responsivo-amico marginvel paddingvalores 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 .25remad 3rem.

Uti CSS Grid layout moduli? Considera usura gap utilitatem loco.

Notatio

Utilitas iustae quae ad omnes confractiones applicat, ab xsiis xxlnullam praevaricationis abbreviationem in illis habet. 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 xset {property}{sides}-{breakpoint}-{size}pro sm, md, lg, xlet xxl.

ubi res una est;

  • m- for classes, quaemargin
  • p- for classes, quaepadding

Ubi laterum unus est;

  • t- pro classes, quae margin-toporipadding-top
  • b- pro classes, quae margin-bottomoripadding-bottom
  • s- (initium) pro generibus pone margin-leftaut padding-leftin LTR, margin-rightaut padding-rightin RTL
  • e- (finem) pro generibus pone margin-rightaut padding-rightin LTR, margin-leftaut padding-leftin RTL .
  • x- pro classes, quae tum *-leftet*-right
  • y- pro classes, quae tum *-topet*-bottom
  • blank - pro classes, quae a marginvel paddingin IV partibus elementi

Ubi magnitudo unius est;

  • 0- pro classes, quae eliminare marginvel paddingcollocare0
  • 1- (per default) pro classes, quae pone marginvel paddingto$spacer * .25
  • 2- (per default) pro classes, quae pone marginvel paddingto$spacer * .5
  • 3- (per default) pro classes, quae pone marginvel paddingto$spacer
  • 4- (per default) pro classes, quae pone marginvel paddingto$spacer * 1.5
  • 5- (per default) pro classes, quae pone marginvel paddingto$spacer * 3
  • auto- pro classes, quae marginad auto-

(Potes amplius addere quantitates addendo ad $spacerstabulam 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-autogenus includit pro horizontaliter centrum fixum-latum rotundum in plano contento, id est, contentum quod habet display: blocket statutum width, ponendo ad margines horizontales auto.

Sitas elementum
<div class="mx-auto" style="width: 200px;">
  Centered element
</div>

Negans margine

In CSS, marginpossessiones valoribus negativis uti possunt ( paddingnon 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 nante quantitatem petitam. Hic exemplum genus quod oppositum .mt-1;

.mt-n1 {
  margin-top: -0.25rem !important;
}

Gap

Cum usus display: grid, uti potes gapin vasis parentis eget. Hoc servare potest, cum utilitates margini addere ad singulas euismod items (filios display: gridcontinentis). Hiatus utilitates ex defectu respondentes sunt, et per utilitates nostras API generantur, ex $spacerstabula Sass.

Eget item 1
Eget item 2
Eget item 3
html
<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 $spacerstabula ( 0- 5). Utilitas non est .gap-autogenus 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,
);

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
    ),
    // Gap utility
    "gap": (
      responsive: true,
      property: gap,
      class: gap,
      values: $spacers
    ),