Beàrnan
Tha Bootstrap a’ toirt a-steach raon farsaing de chlasaichean iomaill freagairteach làmh-ghoirid, pleadhag, agus goireasan beàrn gus coltas eileamaid atharrachadh.
Iomall agus pleadhag
Sònraich luachan càirdeil margin
no padding
freagairteach do eileamaid no fo-sheata de na taobhan aige le clasaichean làmh-ghoirid. A’ toirt a-steach taic do thogalaichean fa leth, gach seilbh, agus togalaichean dìreach is còmhnard. Tha clasaichean air an togail bho mhapa àbhaisteach Sass a’ dol .25rem
bho 3rem
.
Comharrachadh
Chan eil giorrachadh puing-bhriseadh annta aig goireasan farsaing a tha a’ buntainn ris a h-uile puing-briseadh, bho xs
gu . xxl
Tha seo air sgàth gu bheil na clasaichean sin air an cur an sàs bho min-width: 0
agus suas, agus mar sin chan eil iad air an ceangal le ceist mheadhanan. Tha na puingean brisidh a tha air fhàgail, ge-tà, a’ toirt a-steach giorrachadh puing-bhriseadh.
Tha na clasaichean air an ainmeachadh a’ cleachdadh cruth {property}{sides}-{size}
airson xs
agus {property}{sides}-{breakpoint}-{size}
airson sm
, md
, lg
, xl
, agus xxl
.
Far a bheil seilbh mar aon de:
m
- airson clasaichean a tha a 'suidheachadhmargin
p
- airson clasaichean a tha a 'suidheachadhpadding
Far a bheil taobhan mar aon de:
t
- airson clasaichean a shuidhichmargin-top
nopadding-top
b
- airson clasaichean a shuidhichmargin-bottom
nopadding-bottom
s
- (tòiseachadh) airson clasaichean a tha a’ suidheachadhmargin-left
nopadding-left
ann an LTR,margin-right
nopadding-right
ann an RTLe
- (deireadh) airson clasaichean a tha a’ suidheachadhmargin-right
nopadding-right
ann an LTR,margin-left
nopadding-left
ann an RTLx
- airson clasaichean a tha a 'suidheachadh an dà chuid*-left
agus*-right
y
- airson clasaichean a tha a 'suidheachadh an dà chuid*-top
agus*-bottom
- bàn - airson clasaichean a tha a 'suidheachadh
margin
nopadding
air a h-uile 4 taobh den eileamaid
Far a bheil meud mar aon de:
0
- airson clasaichean a chuireas às domargin
nopadding
le bhith ga shuidheachadh0
1
- (gu bunaiteach) airson clasaichean a shuidhich anmargin
nopadding
gu$spacer * .25
2
- (gu bunaiteach) airson clasaichean a shuidhich anmargin
nopadding
gu$spacer * .5
3
- (gu bunaiteach) airson clasaichean a shuidhich anmargin
nopadding
gu$spacer
4
- (gu bunaiteach) airson clasaichean a shuidhich anmargin
nopadding
gu$spacer * 1.5
5
- (gu bunaiteach) airson clasaichean a shuidhich anmargin
nopadding
gu$spacer * 3
auto
- airson clasaichean a tha a 'suidheachadh anmargin
gu fèin-ghluasadach
(Faodaidh tu barrachd mheudan a chur ris le bhith a’ cur inntrigidhean ri $spacers
caochladair mapa Sass.)
Eisimpleirean
Seo eisimpleirean riochdachail de na clasaichean seo:
.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;
}
Ionadachadh còmhnard
A bharrachd air an sin, tha Bootstrap cuideachd a’ toirt a-steach .mx-auto
clas airson susbaint ìre bloc leud stèidhichte gu còmhnard - is e sin, susbaint aig a bheil display: block
agus width
seata - le bhith a ’suidheachadh na h-oirean còmhnard gu auto
.
<div class="mx-auto" style="width: 200px;">
Centered element
</div>
Iomall àicheil
Ann an CSS, margin
faodaidh togalaichean luachan àicheil a chleachdadh ( padding
chan urrainn). Tha na h-iomaill àicheil seo à comas gu bunaiteach , ach faodar an cur an comas ann an Sass le bhith a 'suidheachadh $enable-negative-margins: true
.
Tha an co-chòrdadh cha mhòr an aon rud ris na goireasan iomaill dearbhach, bunaiteach, ach le bhith air a chur ris n
ron mheud a chaidh iarraidh. Seo eisimpleir de chlas a tha mu choinneamh .mt-1
:
.mt-n1 {
margin-top: -0.25rem !important;
}
Beàrn
Nuair a bhios tu a’ cleachdadh display: grid
, faodaidh tu gap
goireasan a chleachdadh air an t-soitheach clèithe phàrant. Faodaidh seo sàbhaladh air a bhith agad ri goireasan iomaill a chur ri nithean clèithe fa leth (clann display: grid
soitheach). Tha goireasan beàrn a’ freagairt gu bunaiteach, agus air an gineadh tro ar goireasan API, stèidhichte air $spacers
mapa 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>
Tha taic a’ toirt a-steach roghainnean freagairteach airson a h-uile puing brisidh clèithe aig Bootstrap, a bharrachd air sia meudan bhon $spacers
mhapa ( 0
- 5
). Chan eil .gap-auto
clas goireis ann oir tha e gu h-èifeachdach an aon rud ri .gap-0
.
Sass
Mapaichean
Bithear a’ cur an cèill goireasan eadar-dhealaichte tro mhapa Sass agus an uairsin air an cruthachadh leis na goireasan API againn.
$spacer: 1rem;
$spacers: (
0: 0,
1: $spacer * .25,
2: $spacer * .5,
3: $spacer,
4: $spacer * 1.5,
5: $spacer * 3,
);
Utilities API
Tha goireasan farsaing air an ainmeachadh anns na goireasan API againn ann an scss/_utilities.scss
. Ionnsaich mar a chleachdas tu an API Utilities.
"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
),