utilitas API
Utilitas API est a Sass-substructio instrumentum ad utilitatem genera generandam.
Utilitas Bootstrap generatur cum utilitate nostra API et adhiberi potest ad modificandam vel extendendam nostrum defectum certae utilitatis per Sass. Utilitas nostra API fundatur in serie mappis Sass et functionibus ad generandas familias classes cum variis optionibus. Si ignotas es cum mappis Sass, lege in officiali Sass docs ut incipias.
Tabula $utilities
geographica continet omnes utilitates nostras et postea cum tua consuetudine inducitur $utilities
, si praesens adest. Utilitas tabula continet indicem coetuum utilitatum clausularum quae sequentes optiones accipiunt:
Option | Type | Default valorem | Descriptio |
---|---|---|---|
property |
required | - | Nomen proprietatis, hoc chorda vel chordarum ordinata (exempli gratia, paddding vel marginibus horizontalibus). |
values |
required | - | Index valorum, vel charta geographica si nomen generis non vis idem esse ac pretium. Si null clavem tabulae adhibet, class nomen classis non praetenditur. |
class |
Libitum | null | Nomine generati classis. Si non provisum property est chordarum ordinatio, class primum elementum property ordinatae deficeret. Si non provisum property est et chorda, values claves sumuntur class nominibus. |
css-var |
Libitum | false |
Boolean generare CSS variabiles pro regulas CSS. |
css-variable-name |
Libitum | null | Custom un-praefixo name for CSS variabilis intra regulaset. |
local-vars |
Libitum | null | Tabula variabilium locorum CSS generandi praeter regulas CSS. |
state |
Libitum | null | Index variantium pseudo-classis (exempli, :hover vel :focus ) generandi. |
responsive |
Libitum | false |
Boolean indicans si classes responsivas generarentur. |
rfs |
Libitum | false |
Boolean ut fluidum rescaling cum RFS . |
print |
Libitum | false |
Boolean indicans si classes print generari necesse est. |
rtl |
Libitum | true |
Boolean indicans si utilitas in RTL. |
API explicavit
Omnis utilitas variabilium $utilities
variabili in nostro _utilities.scss
stylesheet. Uniuscuiusque utilitatis aliquid simile hoc spectat:
$utilities: (
"opacity": (
property: opacity,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
Quae sequuntur outputs:
.opacity-0 { opacity: 0; }
.opacity-25 { opacity: .25; }
.opacity-50 { opacity: .5; }
.opacity-75 { opacity: .75; }
.opacity-100 { opacity: 1; }
Property
Clavis requiritur property
ad quamlibet utilitatem apponi debet, et bona CSS valida continere debet. Haec proprietas in generatae utilitate regulaset usus est. Cum class
clavem omiserit, etiam pro defectu classis nomen habet. text-decoration
utilitatem considera :
$utilities: (
"text-decoration": (
property: text-decoration,
values: none underline line-through
)
);
Output:
.text-decoration-none { text-decoration: none !important; }
.text-decoration-underline { text-decoration: underline !important; }
.text-decoration-line-through { text-decoration: line-through !important; }
Values
Utere values
clavem ad specificandum qui valores ad definitos property
adhibeantur in nominibus et regulis classis generatis. Potest esse index vel tabula (in utilitatibus vel in Sass variabilis posita).
Sicut album, sicut cum text-decoration
utilitate :
values: none underline line-through
Cum charta geographica, sicut cum opacity
utilitate ;
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
Sicut Sass variabilis quae ponit album vel tabulam, sicut in position
utilitatibus nostris :
values: $position-values
Classis
Optione utere class
ut praepositionem mutandi in CSS compilata adhibita. Exempli gratia mutare ab .opacity-*
in .o-*
:
$utilities: (
"opacity": (
property: opacity,
class: o,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
Output:
.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; }
Si class: null
genera singula values
clavium generat:
$utilities: (
"visibility": (
property: visibility,
class: null,
values: (
visible: visible,
invisible: hidden,
)
)
);
Output:
.visible { visibility: visible !important; }
.invisible { visibility: hidden !important; }
CSS variabilis utilitas
css-var
Optionem booleanam pone true
et API variabiles locales CSS generabit pro datis selectoris loco consuetis property: value
regulis. Libitum addere css-variable-name
ut aliud nomen CSS variabile quam nomen classis apponat.
Nostras .text-opacity-*
utilitates considera. Si optionem addimus css-variable-name
, morem output feremus.
$utilities: (
"text-opacity": (
css-var: true,
css-variable-name: text-alpha,
class: text-opacity,
values: (
25: .25,
50: .5,
75: .75,
100: 1
)
),
);
Output:
.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; }
Locus CSS variabiles
Optione utere local-vars
ut describam mappam Sass quae variabiles locales CSS generabit intra regulas ordinis utilitates. Quaeso note quod opus additicium requirat ad sumendas CSS variabiles locales regulas CSS generatae. .bg-*
Verbi gratia, utilitates nostras considera :
$utilities: (
"background-color": (
property: background-color,
class: bg,
local-vars: (
"bg-opacity": 1
),
values: map-merge(
$utilities-bg-colors,
(
"transparent": transparent
)
)
)
);
Output:
.bg-primary {
--bs-bg-opacity: 1;
background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;
}
Foederatae
Ope utere state
ad generandum variationes pseudo-classis. Exemplum pseudo-classes sunt :hover
et :focus
. Cum elenchus statuum provideatur, classnomina illi pseudo-classis creantur. Exempli gratia, opacitatem mutare in volitando, adde state: hover
et habebis .opacity-hover:hover
in compilata CSS.
Pluribus pseudo-classibus opus est? Utere spatio-separato indicem civitatum: state: hover focus
.
$utilities: (
"opacity": (
property: opacity,
class: opacity,
state: hover,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
Output:
.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; }
Responsivum
Boolean adde responsive
utilitates responsivas (exempli gratia .opacity-md-25
) per omnes confractiones generare .
$utilities: (
"opacity": (
property: opacity,
responsive: true,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
Output:
.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; }
}
Optionem print
efficere ut genera utilitatis etiam generabit pro impressis, quae tantum in @media print { ... }
instrumentis quaestionis adhibentur.
$utilities: (
"opacity": (
property: opacity,
print: true,
values: (
0: 0,
25: .25,
50: .5,
75: .75,
100: 1,
)
)
);
Output:
.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; }
}
Momentum
Omnes utilitates ab API generatas includunt !important
ut elementa et determinatio classes prout intenduntur vincant. Hanc ambitum globally $enable-important-utilities
variabili (defaltis true
).
Using the API
Nunc ut sis nota quam utilitas opera API, disce genus morem tuum addere et defectus nostros utilitates mutare.
Override utilitates
Vincat utilitas existentium utendo eadem clavis. Exempli gratia, si voles additis responsivis, superfluis utilibus generibus, hoc facere potes;
$utilities: (
"overflow": (
responsive: true,
property: overflow,
values: visible hidden scroll auto,
),
);
Addere utilitates
Novae utilitates tabulae $utilities
defaltae cum a map-merge
. Fac limas Sass requisitas nostras et _utilities.scss
primum invectas, deinde utere map-merge
ut tuis additis utilitatibus adde. Exempli gratia, hic est utilitas responsiva cursor
cum tribus valoribus addere.
@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";
Modificare utilitates
Modificare utilitates exsistentes in $utilities
tabula geographica defalta cum map-get
et map-merge
functionibus. In exemplo infra addito valorem width
utilitatibus addimus. Incipere cum initiali map-merge
et deinde specificare quam utilitatem vis mutare. Inde tabulam nidificandam affer "width"
cum map-get
accessu ac modulo optionum et bonorum utilitatum.
@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";
Admitte responsive
Classes responsivas efficere potes pro statuto usuum existentium, quae nunc per defaltam non respondeant. Exempli gratia, border
classes responsivas facere:
@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";
Hoc nunc generabit variationes responsivas .border
et .border-0
pro unoquoque breakpoint. Generatae tuae CSS videbunt sic:
.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 { ... }
}
Rename utilitates
Absentis v4 utilitates, vel ad aliam conventionem nominandi usus? Utilitas API adhiberi potest ad consequens class
utilitatem datam delendi-exempli gratia, .ms-*
renominandi utilitates ad vetustatem .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";
Aufer utilitates
Auferte aliquem ex defectu utilitatis cum map-remove()
Sass functione .
@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";
Etiam uti map-merge()
Sass functione et clavis coetus pone ad null
utilitatem tollendam.
@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";
Adde, remove, mutare
Multas utilitates simul cum map-merge()
functione Sass addere, auferre et mutare potes . Ecce quomodo exempla priora in unam maiorem tabulam coniungere potes.
@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";
Remove utilitatem in RTL
Nonnulli casus in margine RTL difficilem faciunt , ut in arabice linea erumpit. Sic utilitates ab output RTL excidere possunt, rtl
optione ad disponendum false
:
$utilities: (
"word-wrap": (
property: word-wrap word-break,
class: text,
values: (break: break-word),
rtl: false
),
);
Output:
/* rtl:begin:remove */
.text-break {
word-wrap: break-word !important;
word-break: break-word !important;
}
/* rtl:end:remove */
Hoc non in RTL output, per RTLCSS remove
imperium directivum .