API taputapu
Ko te API whaipainga he taputapu-a-Sass hei whakaputa i nga karaehe whaipainga.
Ka hangaia nga taputapu Bootstrap me to maatau API whaipainga ka taea te whakamahi ki te whakarereke, ki te whakaroa ranei i a maatau huinga taunoa o nga karaehe whaipainga ma te Sass. Ko ta maatau API whaipainga kei runga i te raupapa o nga mapi Sass me nga mahi mo te whakaputa whanau o nga karaehe me nga momo whiringa. Mena kaore koe i te mohio ki nga mapi Sass, panuihia nga tuhinga a Sass whaimana hei timata.
Kei $utilities
roto i te mapi a maatau taputapu katoa a muri ake ka hanumi ki to $utilities
mapi ritenga, mena kei reira. Kei roto i te mahere whaipainga he rarangi matua o nga roopu whaipainga e whakaae ana ki nga whiringa e whai ake nei:
Kōwhiringa | Momo | Whakaahuatanga |
---|---|---|
property |
E hiahiatia ana | Te ingoa o te taonga, he aho, he huinga aho ranei (hei tauira, he papa whakapae, he tawhē ranei). |
values |
E hiahiatia ana | Te rarangi o nga uara, he mapi ranei ki te kore koe e hiahia kia rite te ingoa o te akomanga ki te uara. Mena null ka whakamahia hei mapi mapi, kaore i te whakahiato. |
class |
Kōwhiringa | Taurangi mo te ingoa akomanga ki te kore koe e pirangi kia rite ki te taonga. Ki te kore koe e whakarato i te class ki me property te matua he huinga aho, ko te ingoa o te akomanga te huānga tuatahi o te property huinga. |
state |
Kōwhiringa | Rarangi o nga momo momo akomanga pseudo rite ki te whakaputa :hover ranei :focus mo te whaipainga. Karekau he uara taunoa. |
responsive |
Kōwhiringa | Boolean e tohu ana mena me hanga nga karaehe urupare. false na te taunoa. |
rfs |
Kōwhiringa | Boolean kia taea ai te whakaheke i te wai. Tirohia te wharangi RFS kia mohio ai me pehea te mahi. false na te taunoa. |
print |
Kōwhiringa | Boolean e tohu ana mena me hanga nga karaehe ta. false na te taunoa. |
rtl |
Kōwhiringa | Ko te Boolean e tohu ana mena ka mau te whaipainga ki RTL. true na te taunoa. |
API whakamarama
Ka taapirihia nga taurangi whaipainga katoa ki te $utilities
taurangi kei roto i ta maatau _utilities.scss
pepa ahua. He penei te ahua o ia roopu taputapu:
$utilities: (
"opacity": (
property: opacity,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
Ko wai e whakaputa ana i nga mea e whai ake nei:
.opacity-0 { opacity: 0; }
.opacity-25 { opacity: .25; }
.opacity-50 { opacity: .5; }
.opacity-75 { opacity: .75; }
.opacity-100 { opacity: 1; }
Kupumua akomanga ritenga
Whakamahia te class
kōwhiringa ki te huri i te pimua akomanga i whakamahia i roto i te CSS whakahiato:
$utilities: (
"opacity": (
property: opacity,
class: o,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
Putanga:
.o-0 { opacity: 0; }
.o-25 { opacity: .25; }
.o-50 { opacity: .5; }
.o-75 { opacity: .75; }
.o-100 { opacity: 1; }
Whenua
Whakamahia te state
kōwhiringa ki te whakaputa rerekētanga akomanga pseudo. Ko nga tauira pseudo-classes he :hover
me :focus
. Ina whakaratohia he rarangi o nga kawanatanga, ka hangaia nga ingoa akomanga mo taua akomanga pseudo. Hei tauira, ki te huri i te opacity i runga i te whakaparo, taapiri state: hover
ka uru koe .opacity-hover:hover
ki to CSS kua whakahiato.
Me maha nga akomanga pseudo? Whakamahia he rarangi wehewehe mokowhiti o nga kawanatanga state: hover focus
:.
$utilities: (
"opacity": (
property: opacity,
class: opacity,
state: hover,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
Putanga:
.opacity-0-hover:hover { opacity: 0 !important; }
.opacity-25-hover:hover { opacity: .25 !important; }
.opacity-50-hover:hover { opacity: .5 !important; }
.opacity-75-hover:hover { opacity: .75 !important; }
.opacity-100-hover:hover { opacity: 1 !important; }
Nga taputapu urupare
Tāpirihia te responsive
boolean ki te whakaputa taputapu urupare (hei tauira, .opacity-md-25
) puta noa i nga waahi pakaru katoa .
$utilities: (
"opacity": (
property: opacity,
responsive: true,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
Putanga:
.opacity-0 { opacity: 0 !important; }
.opacity-25 { opacity: .25 !important; }
.opacity-50 { opacity: .5 !important; }
.opacity-75 { opacity: .75 !important; }
.opacity-100 { opacity: 1 !important; }
@media (min-width: 576px) {
.opacity-sm-0 { opacity: 0 !important; }
.opacity-sm-25 { opacity: .25 !important; }
.opacity-sm-50 { opacity: .5 !important; }
.opacity-sm-75 { opacity: .75 !important; }
.opacity-sm-100 { opacity: 1 !important; }
}
@media (min-width: 768px) {
.opacity-md-0 { opacity: 0 !important; }
.opacity-md-25 { opacity: .25 !important; }
.opacity-md-50 { opacity: .5 !important; }
.opacity-md-75 { opacity: .75 !important; }
.opacity-md-100 { opacity: 1 !important; }
}
@media (min-width: 992px) {
.opacity-lg-0 { opacity: 0 !important; }
.opacity-lg-25 { opacity: .25 !important; }
.opacity-lg-50 { opacity: .5 !important; }
.opacity-lg-75 { opacity: .75 !important; }
.opacity-lg-100 { opacity: 1 !important; }
}
@media (min-width: 1200px) {
.opacity-xl-0 { opacity: 0 !important; }
.opacity-xl-25 { opacity: .25 !important; }
.opacity-xl-50 { opacity: .5 !important; }
.opacity-xl-75 { opacity: .75 !important; }
.opacity-xl-100 { opacity: 1 !important; }
}
@media (min-width: 1400px) {
.opacity-xxl-0 { opacity: 0 !important; }
.opacity-xxl-25 { opacity: .25 !important; }
.opacity-xxl-50 { opacity: .5 !important; }
.opacity-xxl-75 { opacity: .75 !important; }
.opacity-xxl-100 { opacity: 1 !important; }
}
Te huri i nga taputapu
Whakakorehia nga taputapu o naianei ma te whakamahi i te ki taua. Hei tauira, mena kei te pirangi koe ki etahi atu karaehe whaipainga rerenga urupare, ka taea e koe tenei:
$utilities: (
"overflow": (
responsive: true,
property: overflow,
values: visible hidden scroll auto,
),
);
taputapu tā
Ma te whakaahei i te print
kowhiringa ka puta ano nga karaehe whaipainga mo te taa, ka whakamahia i roto noa i te @media print { ... }
patai pāpāho.
$utilities: (
"opacity": (
property: opacity,
print: true,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
Putanga:
.opacity-0 { opacity: 0 !important; }
.opacity-25 { opacity: .25 !important; }
.opacity-50 { opacity: .5 !important; }
.opacity-75 { opacity: .75 !important; }
.opacity-100 { opacity: 1 !important; }
@media print {
.opacity-print-0 { opacity: 0 !important; }
.opacity-print-25 { opacity: .25 !important; }
.opacity-print-50 { opacity: .5 !important; }
.opacity-print-75 { opacity: .75 !important; }
.opacity-print-100 { opacity: 1 !important; }
}
Hiranga
Ko nga taputapu katoa i hangaia e te API ko !important
te whakarite kia takahia e ratou nga waahanga me nga karaehe whakarereke i runga i te whakaaro. Ka taea e koe te huri i tenei tautuhinga puta noa i te ao me te $enable-important-utilities
taurangi (taunoa ki true
).
Ma te whakamahi i te API
Inaianei kua mohio koe ki te mahi a te API taputapu, ako me pehea te taapiri i o ake karaehe ritenga me te whakarereke i o maatau taputapu taunoa.
Tāpiri taputapu
Ka taea te taapiri i nga taputapu hou ki te $utilities
mahere taunoa me te map-merge
. Tirohia o maatau kōnae Sass e hiahiatia ana ka _utilities.scss
kawemai i te tuatahi, katahi ka whakamahi map-merge
hei taapiri i o taputapu taapiri. Hei tauira, me pehea te taapiri i tetahi cursor
taputapu urupare me nga uara e toru.
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities,
(
"cursor": (
property: cursor,
class: cursor,
responsive: true,
values: auto pointer grab,
)
)
);
Whakarerekehia nga taputapu
$utilities
Whakarerekehia nga taputapu kei roto i te mahere taunoa map-get
me nga map-merge
mahi. I roto i te tauira i raro nei, kei te taapirihia e matou he uara taapiri ki nga width
taputapu. Tīmatahia ki te tuatahi map-merge
ka whakapūtā ko tēhea whaipainga e hiahia ana koe ki te whakarerekē. Mai i reira, tikina te "width"
mapi kohanga ki map-get
te uru me te whakarereke i nga whiringa me nga uara o te taputapu.
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities,
(
"width": map-merge(
map-get($utilities, "width"),
(
values: map-merge(
map-get(map-get($utilities, "width"), "values"),
(10: 10%),
),
),
),
)
);
Whakahohe urupare
Ka taea e koe te whakaahei i nga karaehe urupare mo te huinga taputapu o naianei karekau i te whakautu taunoa. Hei tauira, kia border
aro mai nga karaehe:
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities, (
"border": map-merge(
map-get($utilities, "border"),
( responsive: true ),
),
)
);
Ma tenei ka whakaputa i nga rereketanga urupare .border
mo .border-0
ia waahi pakaru. Ka penei te ahua o to CSS hanga:
.border { ... }
.border-0 { ... }
@media (min-width: 576px) {
.border-sm { ... }
.border-sm-0 { ... }
}
@media (min-width: 768px) {
.border-md { ... }
.border-md-0 { ... }
}
@media (min-width: 992px) {
.border-lg { ... }
.border-lg-0 { ... }
}
@media (min-width: 1200px) {
.border-xl { ... }
.border-xl-0 { ... }
}
@media (min-width: 1400px) {
.border-xxl { ... }
.border-xxl-0 { ... }
}
Whakaingoa ano nga taputapu
Kei te ngaro nga taputapu v4, kua whakamahia ranei ki tetahi atu tikanga whakaingoa? Ka taea te whakamahi i nga taputapu API ki te whakakore i nga hua class
o tetahi taputapu kua hoatu—hei tauira, ki te whakaingoa ano .ms-*
i nga taputapu ki te tawhito .ml-*
:
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities, (
"margin-start": map-merge(
map-get($utilities, "margin-start"),
( class: ml ),
),
)
);
Tango taputapu
Tango tetahi o nga taputapu taunoa ma te tautuhi i te matua roopu ki null
. Hei tauira, ki te tango i a maatau width
taputapu katoa, hangahia he $utilities
map-merge
taapiri "width": null
ki roto.
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities,
(
"width": null
)
);
Tango taputapu i roto i te RTL
Ko etahi o nga keehi he uaua ki te whakaahua RTL , penei i nga wehenga raina i te reo Arapi. No reira ka taea te whakaheke i nga taputapu mai i te putanga RTL ma te whakarite i te rtl
whiringa ki false
:
$utilities: (
"word-wrap": (
property: word-wrap word-break,
class: text,
values: (break: break-word),
rtl: false
),
);
Putanga:
/* rtl:begin:remove */
.text-break {
word-wrap: break-word !important;
word-break: break-word !important;
}
/* rtl:end:remove */
Kaore tenei e whakaputa i tetahi mea i roto i te RTL, he mihi ki te mana whakahaere RTLCSSremove
.