Nā kala
Hāʻawi i ka manaʻo ma o color
ka lima o nā papa hana kala. Hoʻokomo pū ʻia ke kākoʻo no ke kālai ʻana i nā loulou me nā mokuʻāina hover.
Nā kala
E kala i ka kikokikona me nā pono kala. Inā makemake ʻoe e kala i nā loulou, hiki iā ʻoe ke hoʻohana i .link-*
nā papa kōkua i loaʻa :hover
a me :focus
nā mokuʻāina.
.text-primary
.text-secondary
.text-success
.text-pilikia
.palapala kikokikona
.text-info
.kukui-kukui
.text-pouli
.kino kikokikona
.mehameha kikokikona
.text-keʻokeʻo
.text-black-50
.text-white-50
<p class="text-primary">.text-primary</p>
<p class="text-secondary">.text-secondary</p>
<p class="text-success">.text-success</p>
<p class="text-danger">.text-danger</p>
<p class="text-warning bg-dark">.text-warning</p>
<p class="text-info bg-dark">.text-info</p>
<p class="text-light bg-dark">.text-light</p>
<p class="text-dark">.text-dark</p>
<p class="text-body">.text-body</p>
<p class="text-muted">.text-muted</p>
<p class="text-white bg-dark">.text-white</p>
<p class="text-black-50">.text-black-50</p>
<p class="text-white-50 bg-dark">.text-white-50</p>
.text-opacity-*
nā pono a me nā ʻano CSS no nā pono kikokikona,
.text-black-50
a
.text-white-50
ua hoʻopau ʻia e like me v5.1.0. Wehe ʻia lākou ma v6.0.0.
Ka lawe ʻana i ka manaʻo i nā ʻenehana kōkua
ʻO ka hoʻohana ʻana i ke kala e hoʻohui i ka manaʻo e hāʻawi wale i kahi hōʻailona ʻike, ʻaʻole e hāʻawi ʻia i nā mea hoʻohana i nā ʻenehana kōkua - e like me nā mea heluhelu pale. E hōʻoia i ka ʻike i hōʻike ʻia e ka waihoʻoluʻu i ʻike ʻia mai ka maʻiʻo ponoʻī (e laʻa i ke kikokikona ʻike ʻia), a i ʻole e hoʻokomo ʻia ma o nā ala ʻē aʻe, e like me nā kikokikona hou i hūnā ʻia me ka .visually-hidden
papa.
Opacity
Hoʻohui ʻia ma v5.1.0E like me v5.1.0, hana ʻia nā pono kala kala me Sass me ka hoʻohana ʻana i nā ʻano CSS. Hiki i kēia ke hoʻololi i ka waihoʻoluʻu manawa maoli me ka ʻole o ka hui ʻana a me ka hoʻololi ʻana o ka alpha transparency.
Pehea e hana ai
E noʻonoʻo i kā mākou mea hoʻohana paʻamau .text-primary
.
.text-primary {
--bs-text-opacity: 1;
color: rgba(var(--bs-primary-rgb), var(--bs-text-opacity)) !important;
}
Hoʻohana mākou i kahi mana RGB o kā mākou --bs-primary
(me ka waiwai o 13, 110, 253
) CSS hoʻololi a hoʻopili i ka lua CSS hoʻololi, --bs-text-opacity
, no ka alpha transparency (me ka waiwai paʻamau 1
mahalo i kahi loli CSS kūloko). ʻO ia hoʻi i kēlā me kēia manawa āu e hoʻohana ai i .text-primary
kēia manawa, ʻo kāu helu color
helu ʻia ʻo rgba(13, 110, 253, 1)
. .text-*
ʻAʻole ʻokoʻa ka ʻokoʻa o ka alpha i hoʻololi ʻia nā mea hoʻololi CSS kūloko i loko o kēlā me kēia papa.
Laʻana
No ka hoʻololi ʻana i kēlā opacity, e hoʻopau --bs-text-opacity
ma o nā kaila maʻamau a i ʻole nā kaila inline.
<div class="text-primary">This is default primary text</div>
<div class="text-primary" style="--bs-text-opacity: .5;">This is 50% opacity primary text</div>
A i ʻole, koho mai kekahi o nā .text-opacity
pono hana:
<div class="text-primary">This is default primary text</div>
<div class="text-primary text-opacity-75">This is 75% opacity primary text</div>
<div class="text-primary text-opacity-50">This is 50% opacity primary text</div>
<div class="text-primary text-opacity-25">This is 25% opacity primary text</div>
kikoo
I kekahi manawa ʻaʻole hiki ke hoʻohana ʻia nā papa contextual ma muli o ke ʻano kikoʻī o kahi mea koho ʻē aʻe. I kekahi mau hihia, ʻo kahi hoʻoponopono kūpono ʻo ia ke kāwili ʻana i ka ʻike o kāu mea i loko o kahi <div>
mea semantic a ʻoi aku paha me ka papa i makemake ʻia.
Sass
Ma waho aʻe o kēia mau hana Sass, e noʻonoʻo e heluhelu e pili ana i kā mākou mau waiwai maʻamau CSS i hoʻokomo ʻia (aka CSS variables) no nā kala a me nā mea hou aku.
Nā mea hoʻololi
Hoʻokumu ʻia ka hapa nui o color
nā pono e kā mākou mau kala kumuhana, i hoʻihoʻi ʻia mai kā mākou mau ʻano palette kala maʻamau.
$blue: #0d6efd;
$indigo: #6610f2;
$purple: #6f42c1;
$pink: #d63384;
$red: #dc3545;
$orange: #fd7e14;
$yellow: #ffc107;
$green: #198754;
$teal: #20c997;
$cyan: #0dcaf0;
$primary: $blue;
$secondary: $gray-600;
$success: $green;
$info: $cyan;
$warning: $yellow;
$danger: $red;
$light: $gray-100;
$dark: $gray-900;
Loaʻa nā kala kalahina, akā hoʻohana ʻia kahi ʻāpana no ka hana ʻana i nā pono hana.
$white: #fff;
$gray-100: #f8f9fa;
$gray-200: #e9ecef;
$gray-300: #dee2e6;
$gray-400: #ced4da;
$gray-500: #adb5bd;
$gray-600: #6c757d;
$gray-700: #495057;
$gray-800: #343a40;
$gray-900: #212529;
$black: #000;
Palapala ʻāina
Hoʻokomo ʻia nā waihoʻoluʻu kumuhana i loko o kahi palapala ʻāina Sass i hiki iā mākou ke hoʻopaʻa i luna o lākou e hana i kā mākou mau pono, nā mea hoʻololi ʻāpana, a me nā mea hou aku.
$theme-colors: (
"primary": $primary,
"secondary": $secondary,
"success": $success,
"info": $info,
"warning": $warning,
"danger": $danger,
"light": $light,
"dark": $dark
);
Loaʻa nā kala kalahina ma ke ʻano he palapala ʻāina Sass. ʻAʻole hoʻohana ʻia kēia palapala ʻāina no ka hana ʻana i nā pono hana.
$grays: (
"100": $gray-100,
"200": $gray-200,
"300": $gray-300,
"400": $gray-400,
"500": $gray-500,
"600": $gray-600,
"700": $gray-700,
"800": $gray-800,
"900": $gray-900
);
Hoʻokumu ʻia nā kala RGB mai kahi palapala ʻāina Sass ʻokoʻa:
$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value");
A kūkulu ʻia nā opacities kala ma luna o kēlā me kā lākou palapala ʻāina ponoʻī i hoʻopau ʻia e nā mea pono API:
$utilities-text: map-merge(
$utilities-colors,
(
"black": to-rgb($black),
"white": to-rgb($white),
"body": to-rgb($body-color)
)
);
$utilities-text-colors: map-loop($utilities-text, rgba-css-var, "$key", "text");
API no nā pono hana
Hōʻike ʻia nā pono kala i kā mākou API ponoʻī ma scss/_utilities.scss
. E aʻo pehea e hoʻohana ai i nā pono API.
"color": (
property: color,
class: text,
local-vars: (
"text-opacity": 1
),
values: map-merge(
$utilities-text-colors,
(
"muted": $text-muted,
"black-50": rgba($black, .5), // deprecated
"white-50": rgba($white, .5), // deprecated
"reset": inherit,
)
)
),
"text-opacity": (
css-var: true,
class: text-opacity,
values: (
25: .25,
50: .5,
75: .75,
100: 1
)
),