API no ka pono
ʻO ka API pono he mea hana Sass e hana i nā papa pono.
Hoʻokumu ʻia nā pono hana Bootstrap me kā mākou API pono a hiki ke hoʻohana ʻia e hoʻololi a hoʻonui i kā mākou papa hana paʻamau ma o Sass. Hoʻokumu ʻia kā mākou mea pono API ma ke ʻano o nā palapala Sass a me nā hana no ka hana ʻana i nā ʻohana o nā papa me nā koho like ʻole. Inā ʻaʻole ʻoe i kamaʻāina i nā palapala ʻāina Sass, e heluhelu i nā palapala Sass mana e hoʻomaka ai.
Loaʻa i ka $utilities
palapala ʻāina kā mākou mau pono āpau a hoʻohui ʻia me kāu $utilities
palapala ʻāina maʻamau, inā aia. Aia ka palapala 'āina i kahi papa inoa o nā hui pono e ʻae i kēia mau koho:
Koho | ʻAno | Waiwai paʻamau | wehewehe |
---|---|---|---|
property |
Pono | – | ʻO ka inoa o ka waiwai, hiki kēia i ke kaula a i ʻole ke ʻano o nā kaula (e laʻa, nā padding horizontal a i ʻole nā palena). |
values |
Pono | – | Ka papa inoa o nā waiwai, a i ʻole ka palapala ʻāina inā ʻaʻole ʻoe makemake e like ka inoa papa me ka waiwai. Inā null hoʻohana ʻia e like me ke kī palapala ʻāina, class ʻaʻole i kau ʻia i ka inoa papa. |
class |
Koho | null | Ka inoa o ka papa i hanaia. Inā ʻaʻole i hāʻawi ʻia a property he ʻano o nā kaula, class e paʻa i ka mea mua o ka property array. Inā ʻaʻole hāʻawi ʻia a property he kaula, values hoʻohana ʻia nā kī no nā class inoa. |
css-var |
Koho | false |
ʻO Boolean e hana i nā mea hoʻololi CSS ma kahi o nā lula CSS. |
css-variable-name |
Koho | null | Ka inoa un-prefixed maʻamau no ka hoʻololi CSS i loko o ka lula. |
local-vars |
Koho | null | Palapala ʻāina o nā ʻano CSS kūloko e hoʻohua i ka hoʻohui i nā lula CSS. |
state |
Koho | null | Papa inoa o nā ʻano ʻano pseudo-class (e laʻa, a i :hover ʻole :focus ) e hana. |
responsive |
Koho | false |
Hōʻike ʻo Boolean inā pono e hana ʻia nā papa pane. |
rfs |
Koho | false |
ʻO Boolean e hiki ai ke hoʻihoʻi hou i ka wai me RFS . |
print |
Koho | false |
Hōʻike ʻo Boolean inā pono e hana ʻia nā papa paʻi. |
rtl |
Koho | true |
Hōʻike ʻo Boolean inā pono e mālama ʻia ka pono ma RTL. |
Ua wehewehe ʻo API
Hoʻohui ʻia nā mea hoʻololi pono āpau i ka $utilities
loli i loko o kā mākou _utilities.scss
stylesheet. ʻO kēlā me kēia hui o nā pono e like me kēia:
$utilities: (
"opacity": (
property: opacity,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
ʻO ka mea e hoʻopuka i kēia mau mea:
.opacity-0 { opacity: 0; }
.opacity-25 { opacity: .25; }
.opacity-50 { opacity: .5; }
.opacity-75 { opacity: .75; }
.opacity-100 { opacity: 1; }
Waiwai
Pono property
e hoʻonoho ʻia ke kī i makemake ʻia no kēlā me kēia pono, a pono e loaʻa kahi waiwai CSS kūpono. Hoʻohana ʻia kēia waiwai i loko o nā lula o ka pono hana. Ke haʻalele ʻia ke class
kī, lilo ia i ka inoa papa paʻamau. E noʻonoʻo i ka text-decoration
pono:
$utilities: (
"text-decoration": (
property: text-decoration,
values: none underline line-through
)
);
Puka:
.text-decoration-none { text-decoration: none !important; }
.text-decoration-underline { text-decoration: underline !important; }
.text-decoration-line-through { text-decoration: line-through !important; }
Waiwai
E hoʻohana i ke values
kī e kuhikuhi i nā waiwai no ka mea i ʻōlelo property
ʻia e hoʻohana ʻia i nā inoa papa i hana ʻia a me nā lula. Hiki i kahi papa inoa a i ʻole palapala ʻāina (i hoʻonohonoho ʻia i loko o nā pono hana a i ʻole ma kahi ʻano Sass).
Ma keʻano he papa inoa, e like me text-decoration
nā pono :
values: none underline line-through
E like me ka palapala 'āina, e like me opacity
nā pono hana :
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
Ma ke ʻano he hoʻololi Sass e hoʻonohonoho i ka papa inoa a i ʻole ka palapala ʻāina, e like me kā mākou mau position
pono :
values: $position-values
Papa
E hoʻohana i ke class
koho e hoʻololi i ka prefix papa i hoʻohana ʻia i ka CSS i hōʻuluʻulu ʻia. No ka laʻana, e hoʻololi mai .opacity-*
i .o-*
:
$utilities: (
"opacity": (
property: opacity,
class: o,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
Puka:
.o-0 { opacity: 0 !important; }
.o-25 { opacity: .25 !important; }
.o-50 { opacity: .5 !important; }
.o-75 { opacity: .75 !important; }
.o-100 { opacity: 1 !important; }
Inā class: null
, hana i nā papa no kēlā me kēia values
kī:
$utilities: (
"visibility": (
property: visibility,
class: null,
values: (
visible: visible,
invisible: hidden,
)
)
);
Puka:
.visible { visibility: visible !important; }
.invisible { visibility: hidden !important; }
ʻO nā pono hoʻololi CSS
E hoʻonoho i ka css-var
koho boolean true
a e hoʻopuka ka API i nā ʻano hoʻololi CSS kūloko no ka mea koho i hāʻawi ʻia ma kahi o nā property: value
lula maʻamau. Hoʻohui i kahi koho css-variable-name
e hoʻonoho i kahi inoa hoʻololi CSS ʻokoʻa ma mua o ka inoa papa.
E noʻonoʻo i kā mākou mau .text-opacity-*
pono. Inā mākou e hoʻohui i ke css-variable-name
koho, e loaʻa iā mākou kahi huahana maʻamau.
$utilities: (
"text-opacity": (
css-var: true,
css-variable-name: text-alpha,
class: text-opacity,
values: (
25: .25,
50: .5,
75: .75,
100: 1
)
),
);
Puka:
.text-opacity-25 { --bs-text-alpha: .25; }
.text-opacity-50 { --bs-text-alpha: .5; }
.text-opacity-75 { --bs-text-alpha: .75; }
.text-opacity-100 { --bs-text-alpha: 1; }
Nā hoʻololi CSS kūloko
E hoʻohana i ke local-vars
koho e kuhikuhi i kahi palapala ʻāina Sass e hoʻohua i nā mea hoʻololi CSS kūloko i loko o ka lula o ka papa pono. E ʻoluʻolu e koi ʻia paha ka hana hou e hoʻopau i kēlā mau ʻano CSS kūloko i nā lula CSS i hana ʻia. No ka laʻana, e noʻonoʻo i kā mākou .bg-*
mea pono:
$utilities: (
"background-color": (
property: background-color,
class: bg,
local-vars: (
"bg-opacity": 1
),
values: map-merge(
$utilities-bg-colors,
(
"transparent": transparent
)
)
)
);
Puka:
.bg-primary {
--bs-bg-opacity: 1;
background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;
}
Mokuʻāina
E hoʻohana i ke state
koho e hana i nā ʻano like ʻole pseudo-class. ʻO nā laʻana pseudo-papa :hover
a me :focus
. Ke hāʻawi ʻia kahi papa inoa o nā mokuʻāina, hana ʻia nā papa inoa no kēlā pseudo-class. No ka laʻana, e hoʻololi i ka opacity ma ka hover, hoʻohui state: hover
a loaʻa iā .opacity-hover:hover
ʻoe i kāu CSS i hui ʻia.
Pono nā papa pseudo he nui? E hoʻohana i kahi papa inoa o nā mokuʻāina i hoʻokaʻawale ʻia: state: hover focus
.
$utilities: (
"opacity": (
property: opacity,
class: opacity,
state: hover,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
Puka:
.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; }
Pane
Hoʻohui i ka responsive
boolean e hana i nā pono hana pane (e laʻa, .opacity-md-25
) ma nā wahi haʻi āpau .
$utilities: (
"opacity": (
property: opacity,
responsive: true,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
Puka:
.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; }
}
Paʻi
ʻO ka ʻae ʻana i ke print
koho e hoʻopuka pū i nā papa pono no ka paʻi ʻana, i hoʻohana wale ʻia i loko o ka @media print { ... }
nīnau media.
$utilities: (
"opacity": (
property: opacity,
print: true,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
Puka:
.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; }
}
Mea nui
ʻO nā pono hana a pau i hana ʻia e ka API !important
e hōʻoiaʻiʻo e hoʻopau lākou i nā ʻāpana a me nā papa hoʻololi e like me ka manaʻo. Hiki iā ʻoe ke hoʻololi i kēia hoʻonohonoho ma ke ao holoʻokoʻa me ka $enable-important-utilities
hoʻololi (paʻamau i true
).
Ke hoʻohana nei i ka API
I kēia manawa ua kamaʻāina ʻoe i ka hana ʻana o ka API ponoʻī, e aʻo pehea e hoʻohui i kāu mau papa maʻamau a hoʻololi i kā mākou mau pono ponoʻī.
Hoʻopau i nā pono hana
Hoʻopau i nā pono hana e hoʻohana ana i ke kī like. No ka laʻana, inā makemake ʻoe i nā papa hana hoʻopihapiha hoʻopihapiha pane hou, hiki iā ʻoe ke hana i kēia:
$utilities: (
"overflow": (
responsive: true,
property: overflow,
values: visible hidden scroll auto,
),
);
Hoʻohui i nā pono hana
$utilities
Hiki ke hoʻohui ʻia nā pono hana hou i ka palapala ʻāina paʻamau me kahi map-merge
. E hōʻoia i kā mākou mau faila Sass pono a _utilities.scss
lawe ʻia ma mua, a laila e hoʻohana i ka mea map-merge
e hoʻohui i kāu mau pono. No ka laʻana, eia pehea e hoʻohui ai i kahi cursor
pono pane me nā waiwai ʻekolu.
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities,
(
"cursor": (
property: cursor,
class: cursor,
responsive: true,
values: auto pointer grab,
)
)
);
@import "bootstrap/scss/utilities/api";
Hoʻololi i nā pono hana
$utilities
Hoʻololi i nā pono hana ma ka palapala ʻāina paʻamau me map-get
nā map-merge
hana. Ma ka laʻana ma lalo nei, ke hoʻohui nei mākou i kahi waiwai hou i nā width
pono hana. E hoʻomaka me kahi mea mua map-merge
a laila e kuhikuhi i ka pono āu e makemake ai e hoʻololi. Mai laila mai, e kiʻi i ka "width"
palapala ʻāina pūnana me map-get
ke komo a hoʻololi i nā koho a me nā waiwai o ka pono.
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@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%),
),
),
),
)
);
@import "bootstrap/scss/utilities/api";
Hiki ke pane
Hiki iā ʻoe ke ʻae i nā papa pane no kahi hoʻonohonoho o nā pono hana i pane ʻole ʻia i kēia manawa. No ka laʻana, no ka border
pane ʻana i nā papa:
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities, (
"border": map-merge(
map-get($utilities, "border"),
( responsive: true ),
),
)
);
@import "bootstrap/scss/utilities/api";
E hana kēia i nā ʻano like ʻole o kēlā .border
me .border-0
kēia breakpoint. ʻO kāu CSS i hana ʻia e like me kēia:
.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 { ... }
}
Hoʻololi inoa i nā pono hana
Nalo nā pono v4, a i ʻole i hoʻohana ʻia i kahi hui inoa ʻē aʻe? Hiki ke hoʻohana ʻia ka API no ka hoʻopau ʻana i ka hopena class
o kahi pono i hāʻawi ʻia - no ka laʻana, e hoʻololi i ka inoa .ms-*
o nā pono hana i ka oldish .ml-*
:
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities, (
"margin-start": map-merge(
map-get($utilities, "margin-start"),
( class: ml ),
),
)
);
@import "bootstrap/scss/utilities/api";
Wehe i nā pono hana
Wehe i kekahi o nā pono hana paʻamau me ka map-remove()
hana Sass .
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
// Remove multiple utilities with a comma-separated list
$utilities: map-remove($utilities, "width", "float");
@import "bootstrap/scss/utilities/api";
Hiki iā ʻoe ke hoʻohana i ka map-merge()
hana Sass a hoʻonohonoho i ke kī hui null
e wehe i ka pono.
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities,
(
"width": null
)
);
@import "bootstrap/scss/utilities/api";
Hoʻohui, wehe, hoʻololi
Hiki iā ʻoe ke hoʻohui, wehe, a hoʻololi i nā mea pono he nui i ka manawa hoʻokahi me ka map-merge()
hana Sass . Eia pehea ʻoe e hoʻohui ai i nā laʻana mua i hoʻokahi palapala ʻāina nui aʻe.
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
$utilities: map-merge(
$utilities,
(
// Remove the `width` utility
"width": null,
// Make an existing utility responsive
"border": map-merge(
map-get($utilities, "border"),
( responsive: true ),
),
// Add new utilities
"cursor": (
property: cursor,
class: cursor,
responsive: true,
values: auto pointer grab,
)
)
);
@import "bootstrap/scss/utilities/api";
Wehe i ka pono ma RTL
ʻO kekahi mau hihia lihi e paʻakikī i ka hana ʻana i ka RTL , e like me nā laina laina ma ka ʻōlelo ʻAlapia. No laila hiki ke hoʻokuʻu ʻia nā pono hana mai RTL output ma ka hoʻonohonoho ʻana i ke rtl
koho i false
:
$utilities: (
"word-wrap": (
property: word-wrap word-break,
class: text,
values: (break: break-word),
rtl: false
),
);
Puka:
/* rtl:begin:remove */
.text-break {
word-wrap: break-word !important;
word-break: break-word !important;
}
/* rtl:end:remove */
ʻAʻole kēia e hoʻopuka i kekahi mea ma RTL, mahalo i ke kuhikuhi mana RTLCSSremove
.