Xim
Bootstrap tau txais kev txhawb nqa los ntawm cov xim uas nws kim heev uas cov ntsiab lus peb cov qauv thiab cov khoom. Qhov no ua rau muaj kev hloov kho ntau dua thiab txuas ntxiv rau txhua qhov haujlwm.
Xim xim
Peb siv subset ntawm tag nrho cov xim los tsim ib tug me me xim palette rau tsim xim schemes, kuj muaj raws li Sass variables thiab ib daim ntawv qhia Sass nyob rau hauv Bootstrap cov scss/_variables.scss
ntaub ntawv.
Tag nrho cov xim no muaj nyob rau hauv daim ntawv qhia Sass, $theme-colors
.
$theme-colors: (
"primary": $primary,
"secondary": $secondary,
"success": $success,
"info": $info,
"warning": $warning,
"danger": $danger,
"light": $light,
"dark": $dark
);
Mus saib peb Sass maps thiab loops docs kom hloov cov xim no.
Txhua xim
Txhua Bootstrap xim muaj nyob rau hauv Sass variables thiab Sass daim ntawv qhia hauv scss/_variables.scss
cov ntaub ntawv. Txhawm rau zam kom tsis txhob muaj cov ntaub ntawv ntau ntxiv, peb tsis tsim cov ntawv nyeem lossis cov chav kawm xim tom qab rau txhua qhov sib txawv no. Xwb, peb xaiv ib pawg ntawm cov xim no rau lub ntsiab palette .
Nco ntsoov saib xyuas qhov sib piv piv thaum koj hloov xim. Raws li qhia hauv qab no, peb tau ntxiv peb qhov sib piv rau txhua qhov xim tseem ceeb - ib qho rau cov xim tam sim no, ib qho rau tawm tsam dawb, thiab ib qho rau tawm tsam dub.
Sau ntawv rau Sass
Sass tsis tuaj yeem programmatically tsim qhov sib txawv, yog li peb manually tsim cov hloov pauv rau txhua qhov xim thiab ntxoov ntxoo peb tus kheej. Peb qhia kom meej tus nqi nruab nrab (piv txwv li, $blue-500
) thiab siv cov xim kev cai rau tint (lighten) lossis ntxoov ntxoo (tsaus) peb cov xim ntawm Sass cov mix()
xim muaj nuj nqi.
Kev siv mix()
tsis zoo ib yam li lighten()
thiab darken()
- yav dhau los muab cov xim tshwj xeeb nrog xim dawb lossis xim dub, thaum lub sijhawm tom kawg tsuas yog kho tus nqi lightness ntawm txhua xim. Qhov tshwm sim yog ib qho kev ua tiav ntau ntawm cov xim, raws li qhia hauv CodePen demo .
Peb tint-color()
thiab shade-color()
kev ua haujlwm siv mix()
nrog rau peb $theme-color-interval
qhov sib txawv, uas qhia txog tus nqi feem pua ntawm txhua qhov sib xyaw xim peb tsim. Saib cov ntawv scss/_functions.scss
thiab scss/_variables.scss
cov ntaub ntawv rau tag nrho qhov chaws.
Xim Sass maps
Bootstrap qhov chaw Sass cov ntaub ntawv suav nrog peb daim ntawv qhia los pab koj sai thiab yooj yim voj hla cov npe ntawm cov xim thiab lawv cov txiaj ntsig hex.
$colors
teev tag nrho peb lub hauv paus (500
) xim$theme-colors
sau tag nrho cov npe semantically lub ntsiab xim (pom hauv qab no)$grays
sau tag nrho cov tints thiab ntxoov grey
Tsis pub dhau scss/_variables.scss
, koj yuav pom Bootstrap cov xim sib txawv thiab Sass daim ntawv qhia. Nov yog ib qho piv txwv ntawm $colors
Sass map:
$colors: (
"blue": $blue,
"indigo": $indigo,
"purple": $purple,
"pink": $pink,
"red": $red,
"orange": $orange,
"yellow": $yellow,
"green": $green,
"teal": $teal,
"cyan": $cyan,
"white": $white,
"gray": $gray-600,
"gray-dark": $gray-800
);
Ntxiv, tshem tawm, lossis hloov kho qhov tseem ceeb hauv daim duab qhia kev hloov kho lawv siv li cas hauv ntau lwm yam. Hmoov tsis zoo nyob rau lub sijhawm no, tsis yog txhua yam khoom siv siv daim ntawv qhia Sass no. Cov kev hloov tshiab yav tom ntej yuav siv zog los txhim kho qhov no. Txog thaum ntawd, npaj rau kev siv cov ${color}
hloov pauv thiab daim ntawv qhia Sass no.
Piv txwv
Nov yog qhov koj tuaj yeem siv cov no hauv koj Sass:
.alpha { color: $purple; }
.beta {
color: $yellow-300;
background-color: $indigo-900;
}
Cov chav kawm siv xim thiab keeb kwm yav dhau los kuj muaj rau kev teeb tsa color
thiab background-color
siv cov 500
xim xim.