Izinkinobho
Sebenzisa izitayela zezinkinobho zangokwezifiso ze-Bootstrap ngezenzo ngamafomu, izingxoxo, nokuningi ngosekelo losayizi abaningi, izifunda, nokuningi.
Izibonelo
I-Bootstrap ifaka phakathi izitayela zezinkinobho ezichazwe ngaphambilini, ngasinye sisebenzisa inhloso yaso ye-semantic, kanye nokwengeziwe okumbalwa okuphonswe ukuze kulawulwe okwengeziwe.
Ukudlulisa incazelo kubuchwepheshe obusizayo
Ukusebenzisa umbala ukwengeza incazelo kunikeza kuphela inkomba ebonakalayo, engeke idluliselwe kubasebenzisi bobuchwepheshe obusizayo - njengezifundi zesikrini. Qinisekisa ukuthi ulwazi olushiwo umbala lusobala kokuqukethwe ngokwako (isb umbhalo obonakalayo), noma lufakwe ngezinye izindlela, njengombhalo owengeziwe ofihliwe .sr-only
nekilasi.
Khubaza ukugoqa umbhalo
Uma ungafuni ukuthi umbhalo wenkinobho ugoqwe, ungangeza .text-nowrap
iklasi enkinobho. Ku-Sass, ungasetha $btn-white-space: nowrap
ukukhubaza ukugoqa umbhalo kunkinobho ngayinye.
Omaka bezinkinobho
Amakilasi .btn
aklanyelwe ukusetshenziswa ne- <button>
elementi. Kodwa-ke, ungasebenzisa la makilasi kuwo <a>
noma <input>
izakhi (yize ezinye iziphequluli zingasebenzisa ukunikezwa okuhlukile kancane).
Uma usebenzisa izinkinobho zamakilasi <a>
ezici ezisetshenziselwa ukuqalisa ukusebenza kwekhasi (njengokuqukethwe okugoqiwe), esikhundleni sokuxhuma emakhasini amasha noma izigaba ezingaphakathi kwekhasi lamanje, lezi zixhumanisi kufanele zinikezwe role="button"
ukuze zidlulisele injongo yazo ngendlela efanele kubuchwepheshe obusizayo obufana no. izifundi zesikrini.
Izinkinobho zohlaka
Udinga inkinobho, kodwa hhayi imibala yangemuva enzima abayilethayo? Miselela amakilasi okulungisa azenzakalelayo .btn-outline-*
nalawo ukuze ususe zonke izithombe ezingemuva nemibala kunoma iyiphi inkinobho.
Osayizi
Uyathanda izinkinobho ezinkulu noma ezincane? Engeza .btn-lg
noma .btn-sm
osayizi abengeziwe.
Dala izinkinobho zeleveli yebhulokhi—lezo ezinobubanzi obugcwele bomzali—ngokwengeza .btn-block
.
Isimo esisebenzayo
Izinkinobho zizovela zicindezelwe (ezinengemuva elimnyama, umngcele omnyama, nesithunzi esifakiwe) uma isebenza. Asikho isidingo sokwengeza iklasi ku- <button>
s njengoba zisebenzisa i-pseudo-class . Nokho, usengaphoqa ukubonakala okufanayo okusebenzayo nge .active
(futhi ufake aria-pressed="true"
isibaluli) uma udinga ukuphindaphinda isimo ngokohlelo.
Isimo sokukhubazeka
Yenza izinkinobho zibukeke zingasebenzi ngokwengeza disabled
isibaluli se-boolean kunoma iyiphi i- <button>
elementi.
Izinkinobho ezikhutshaziwe ezisebenzisa i- <a>
elementi ziziphatha ngendlela ehlukile:
<a>
s azisekelidisabled
isibaluli, ngakho-ke kufanele wengeze.disabled
ikilasi ukuze ulenze libonakale likhubazekile.- Ezinye izitayela ezilungele ikusasa zifakiwe ukuze kukhubazwe konke
pointer-events
kuzinkinobho zehange. Kuziphequluli ezisekela leso sakhiwo, ngeke usibone nakancane ikhesa ekhutshaziwe. - Izinkinobho ezikhutshaziwe kufanele zifake
aria-disabled="true"
isibaluli ukuze zibonise isimo se-elementi kubuchwepheshe obusizayo.
Xhumanisa i-caveat yokusebenza
Ikilasi .disabled
lisebenzisa pointer-events: none
ukuzama ukukhubaza ukusebenza kwesixhumanisi kuka- <a>
s, kodwa leyo mpahla ye-CSS ayikakamiswanga. Ngaphezu kwalokho, nasezipheqululini ezisekelayo pointer-events: none
, ukuzulazula kwekhibhodi kuhlala kungathinteki, okusho ukuthi abasebenzisi bekhibhodi ababonayo nabasebenzisi bobuchwepheshe obusizayo basazokwazi ukwenza lezi zixhumanisi zisebenze. Ukuze uphephe, engeza tabindex="-1"
isibaluli kulezi zixhumanisi (ukuze uzivikele ekutholeni ukugxila kwekhibhodi) futhi usebenzise i-JavaScript yangokwezifiso ukuze ukhubaze ukusebenza kwazo.
I-plugin yenkinobho
Yenza okwengeziwe ngezinkinobho. Inkinobho yokulawula ithi noma dala amaqembu ezinkinobho zezingxenye ezengeziwe njengamabha wamathuluzi.
Guqula izifundazwe
Engeza data-toggle="button"
ukuze uguqule isimo senkinobho active
. Uma uguqula ngaphambili inkinobho, kufanele wengeze .active
ikilasi mathupha kanye aria-pressed="true"
naku- <button>
.
Ibhokisi lokuhlola nezinkinobho zomsakazo
Izitayela ze -Bootstrap .button
zingasetshenziswa kwezinye izici, ezifana no- <label>
s, ukunikeza ibhokisi lokuhlola noma inkinobho yesitayela somsakazo. Engeza data-toggle="buttons"
kokuqukethe .btn-group
lezo zinkinobho eziguquliwe ukuze unike amandla ukuziphatha kwazo kokuguqula nge-JavaScript futhi wengeze .btn-group-toggle
kusitayela u- <input>
s ngaphakathi kwezinkinobho zakho. Qaphela ukuthi ungakha izinkinobho ezinamandla okufakwayo okukodwa noma amaqembu azo.
Isimo esithikhiwe salezi zinkinobho sibuyekezwa kuphela click
ngomcimbi osenkinobho. Uma usebenzisa enye indlela ukuze ubuyekeze okokufaka—isb, usebenzisa <input type="reset">
noma ngokufaka checked
impahla yokokufaka ngokwakho—kuzodingeka uguqule .active
ngokuzenzela <label>
.
Qaphela ukuthi izinkinobho ezihloliwe zidinga ukuthi ungeze .active
ikilasi mathupha kokokufaka <label>
.
Izindlela
Indlela | Incazelo |
---|---|
$().button('toggle') |
Iguqula isimo sohlelo. Inikeza inkinobho ukubonakala sengathi yenziwe yasebenza. |
$().button('dispose') |
Icekela phansi inkinobho yento. |