Midabka
Bootstrap waxaa taageera nidaam midab leh oo ballaaran kaas oo mawduuca ka dhigaya qaababkayada iyo qaybahayada. Tani waxay awood u siinaysaa habaynta iyo fidinta mashruuc kasta.
Midabada mawduuca
Waxaan isticmaalnaa qayb ka mid ah dhammaan midabada si aan u abuurno palette midab yar si loo soo saaro nidaamyada midabka, sidoo kale loo heli karo doorsoomayaasha Sass iyo khariidadda Sass ee scss/_variables.scss
faylka Bootstrap.
Dhammaan midabadani waxay diyaar u yihiin sida khariidadda Sass, $theme-colors
.
$theme-colors: (
"primary": $primary,
"secondary": $secondary,
"success": $success,
"info": $info,
"warning": $warning,
"danger": $danger,
"light": $light,
"dark": $dark
);
Fiiri khariidadahayada Sass iyo dokumentiyada loops -yada sida loo beddelo midabadaas.
Dhammaan midabada
Dhammaan midabada Bootstrap waxay diyaar u yihiin doorsoomayaasha Sass iyo khariidadda Sass ee scss/_variables.scss
faylka. Si looga fogaado kordhinta cabbirrada faylalka, uma samaynayno qoraal ama fasalo midab gadaasha mid kasta oo ka mid ah doorsoomayaashan. Taa baddalkeeda, waxaan dooranaa qayb-hoosaadyadan midabada ah ee palette mawduuca .
U hubso inaad la socoto saamiga isbarbardhiga marka aad habaynayso midabada. Sida hoos ku cad, waxaanu ku darnay saddex is barbar dhig mid kasta oo ka mid ah midabada ugu muhiimsan - mid loogu talagalay midabada swatch ee hadda, mid ka soo horjeeda caddaan, iyo mid ka soo horjeeda madow.
Qoraalada Sass
Sass barnaamij ahaan ma dhalin karo doorsoomayaasha, sidaa awgeed waxaanu gacanteena ku abuurnay doorsoomayaasha midab kasta oo nafaheena hadh. Waxaan qeexnaa qiimaha bartanka dhexe (tusaale, $blue-500
) waxaana isticmaalnaa shaqooyinka midabka caadiga ah si aan u midabeeyo (loo iftiimiyo) ama u hadhno (madoobaado) midabadayada iyada oo loo marayo mix()
shaqada midabka Sass.
Isticmaalka mix()
la mid ma aha lighten()
iyo darken()
— kii hore waxa uu isku daraa midabka la cayimay oo leh caddaan ama madow, halka kan dambe uu kaliya hagaajiyo qiimaha iftiinka midab kasta. Natiijadu waa midabyo aad u dhammaystiran, sida ku cad CodePen demo .
Shaqadeena tint-color()
iyo shade-color()
hawlaheenna waxay mix()
la adeegsadaan $theme-color-interval
doorsoomayaashayada, kaas oo qeexaya qiimaha boqolleyda la talaabsaday ee midab kasta oo isku dhafan oo aan soo saarno. Fiiri faylasha scss/_functions.scss
iyo scss/_variables.scss
koodka isha oo dhan.
Maabka Sass Midabka
Bootstrap's isha Faylasha Sass waxaa ka mid ah saddex khariidado si ay kaaga caawiyaan si dhakhso leh oo fudud u dulmar liiska midabada iyo qiyamkooda hex.
$colors
wuxuu taxayaa dhammaan500
midabada salka diyaarka ah$theme-colors
taxayaa dhammaan midabada mawduucyada si macne ahaan loo magacaabay (hoos lagu muujiyey)$grays
wuxuu taxayaa dhammaan midabada iyo hadhka cawliga
Gudaha scss/_variables.scss
, waxaad ka heli doontaa doorsoomayaasha midabka Bootstrap iyo khariidadda Sass. Waa kuwan tusaale $colors
khariidadda Sass:
$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
);
Ku dar, ka saar, ama wax ka beddel qiyamka khariidada dhexdeeda si aad u cusboonaysiiso sida loogu isticmaalo qaybo kale oo badan. Nasiib darro wakhtigan, ma aha qayb kasta oo ka faa'iidaysata khariidadan Sass. Cusboonaysiinta mustaqbalka waxay ku dadaali doontaa inay horumariso tan. Ilaa markaas, qorshee isticmaalka ${color}
doorsoomayaasha iyo khariidadan Sass.
Tusaale
Waa kuwan sida aad kuwan ugu isticmaali karto Sass-kaaga:
.alpha { color: $purple; }
.beta {
color: $yellow-300;
background-color: $indigo-900;
}
Midabka iyo fasallada utility asalka ayaa sidoo kale diyaar u ah dejinta color
iyo background-color
isticmaalka 500
qiimaha midabka.
Soo saarista tamarta
Lagu daray v5.1.0
Bootstrap kuma jiraan color
iyo background-color
utility doorsoome kasta oo midab leh, laakiin adiga qudhaadu kuwan ayaad ku abuuri kartaa API utility our iyo khariidadaha Sass ee fidsan ee lagu daray v5.1.0.
- Si aad u bilawdo, hubi inaad soo dejisay hawlaheenna, doorsoomayaasha, isku-darka, iyo adeegyadayada.
- Isticmaal shaqadayada
map-merge-multiple()
si aad si dhakhso leh ugu milmaan khariidado badan oo Sass ah khariidad cusub. - Ku dar khariidaddan cusub ee la isku daray si loo kordhiyo adeeg kasta oo leh
{color}-{level}
magac fasalka.
Waa kuwan tusaale soo saara agabka midabka qoraalka (tusaale, .text-purple-500
) adoo isticmaalaya tillaabooyinka kore.
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
$all-colors: map-merge-multiple($blues, $indigos, $purples, $pinks, $reds, $oranges, $yellows, $greens, $teals, $cyans);
$utilities: map-merge(
$utilities,
(
"color": map-merge(
map-get($utilities, "color"),
(
values: map-merge(
map-get(map-get($utilities, "color"), "values"),
(
$all-colors
),
),
),
),
)
);
@import "bootstrap/scss/utilities/api";
Tani waxay dhalin doontaa .text-{color}-{level}
utility cusub midab kasta iyo heer kasta. Waxaad sidaas oo kale u samayn kartaa tas-hiilaadka kale iyo hantida sidoo kale.