Amaqhosha
Sebenzisa izimbo zeqhosha le-Bootstrap ukwenza izinto kwiifom, iingxoxo, kunye nokunye ngenkxaso yeesayizi ezininzi, amazwe, kunye nokunye.
Imizekelo
I-Bootstrap ibandakanya izitayile zamaqhosha achazwe kwangaphambili, nganye isebenzela injongo yayo ye-semantic, kunye nokongezwa okumbalwa okuphoswe kulawulo olungaphezulu.
Ukuhambisa intsingiselo kwiiteknoloji ezincedisayo
Ukusebenzisa umbala ukongeza intsingiselo kubonelela kuphela ngesalathiso esibonakalayo, esingayi kuthunyelwa kubasebenzisi betekhnoloji encedisayo - njengezifundi zesikrini. Qinisekisa ukuba ulwazi olubonakaliswe ngumbala lucacile kumxholo ngokwawo (umzekelo, umbhalo obonakalayo), okanye luqukwe ngezinye iindlela, ezifana nesicatshulwa esongezelelweyo esifihlwe .sr-only
eklasini.
Khubaza ukusonga umbhalo
Ukuba awufuni ukuba umbhalo weqhosha usongelwe, unokongeza .text-nowrap
iklasi kwiqhosha. Kwi-Sass, unokuseta $btn-white-space: nowrap
ukuvala ukuvalwa kokubhaliweyo kwiqhosha ngalinye.
Iithegi zeqhosha
Iiklasi .btn
ziyilelwe ukuba zisetyenziswe kunye <button>
nesiqalelo. Nangona kunjalo, ungasebenzisa ezi klasi kwi <a>
okanye <input>
izinto (nangona ezinye iibhrawuza zinokusebenzisa unikezelo olwahluke kancinane).
Xa usebenzisa iiklasi zamaqhosha <a>
kwizinto ezisetyenziselwa ukuqalisa ukusebenza kwekhasi (njengomxholo odilikayo), endaweni yokudibanisa amaphepha amatsha okanye amacandelo angaphakathi kwephepha langoku, la makhonkco kufuneka anikwe role="button"
ukuhambisa ngokufanelekileyo injongo yawo kubuchwephesha obuncedisayo njenge abafundi besikrini.
Amaqhosha enkcazo
Ngaba ufuna iqhosha, kodwa hayi imibala engasemva enzima abayizisayo? Buyisela iiklasi zesilungisi esingagqibekanga ngezo .btn-outline-*
zokususa yonke imifanekiso yangasemva kunye nemibala kulo naliphi na iqhosha.
Ubukhulu
Unqwenela amaqhosha amakhulu okanye amancinci? Yongeza .btn-lg
okanye .btn-sm
iisayizi ezongezelelweyo.
Yenza amaqhosha omgangatho webhlokhi—awo anobubanzi obupheleleyo bomzali—ngokongeza .btn-block
.
Imeko esebenzayo
Amaqhosha azakuvela ecinezelwe (ngemvelaphi emnyama, umda omnyama, kunye nesithunzi somfanekiso) xa usebenza. Akukho mfuneko yokongeza iklasi ku- <button>
s njengoko besebenzisa i-pseudo-class . Nangona kunjalo, usenakho ukunyanzela inkangeleko efanayo esebenzayo kunye .active
(kwaye ubandakanye aria-pressed="true"
uphawu) ukuba ufuna ukuphinda urhulumente ngokwenkqubo.
Ilizwe labakhubazekileyo
Yenza amaqhosha abonakale engasebenzi ngokongeza disabled
uphawu lwe boolean kuyo nayiphi na <button>
into.
Amaqhosha angasebenziyo asebenzisa <a>
isiqalelo aziphatha ngokwahlukileyo:
<a>
s ayiluxhasidisabled
uphawu, ngoko ke kufuneka udibanise.disabled
iklasi ukuyenza ibonakale ingasebenzi.- Ezinye izimbo ezilungele ixesha elizayo zibandakanyiwe ukuvala zonke
pointer-events
kumaqhosha eankile. Kwibhrawuza ezixhasa lo propati, awuzukubona ikhesa ekhubazekileyo kwaphela. - Amaqhosha avaliweyo kufuneka abandakanye
aria-disabled="true"
uphawu lokubonisa imeko yento kwiitekhnoloji ezincedisayo.
Icaveat yokusebenza kwekhonkco
Iklasi .disabled
isebenzisa pointer-events: none
ukuzama ukukhubaza usebenziso lwekhonkco lwe- <a>
s, kodwa loo propati ye-CSS ayikabikho emgangathweni. Ukongeza, nakwiziphequluli ezixhasayo pointer-events: none
, ukukhangela kwekhibhodi kuhlala kungachaphazeleki, okuthetha ukuba abasebenzisi bekhibhodi ababoniweyo kunye nabasebenzisi bobuchwephesha bokuncedisa baya kuba nakho ukwenza la makhonkco asebenze. Ke ukuze ukhuseleke, yongeza tabindex="-1"
uphawu kula makhonkco (ukuwathintela ekufumaneni ujoliso lwebhodi yezitshixo) kwaye usebenzise iJavaScript yesiko ukukhubaza ukusebenza kwabo.
Iqhosha leplagi
Yenza ngakumbi ngamaqhosha. Iqhosha lokulawula lixela okanye wenze amaqela amaqhosha amalungu amaninzi njengebar yesixhobo.
Guqula amazwe
Yongeza data-toggle="button"
ukuguqula imeko yeqhosha active
. Ukuba ucofa ngaphambili iqhosha, kufuneka udibanise .active
iklasi ngesandla kwaye aria-pressed="true"
kwi <button>
.
Ibhokisi yokukhangela kunye namaqhosha erediyo
Izitayile zeBootstrap .button
zinokusetyenziswa kwezinye izinto, ezinje nge- <label>
s, ukunika ibhokisi yokukhangela okanye iqhosha lesimbo serediyo. Yongeza data-toggle="buttons"
kwi .btn-group
equlathe loo maqhosha alungisiweyo ukwenza ukuziphatha kwawo ujiko ngeJavaScript kwaye wongeze .btn-group-toggle
kwisimbo i <input>
s ngaphakathi kwamaqhosha akho. Qaphela ukuba ungenza amaqhosha afakwe amandla elinye okanye amaqela awo.
Imo ekhangelweyo kula maqhosha ihlaziywa kuphela click
ngesiganeko kwiqhosha. Ukuba usebenzisa enye indlela yokuhlaziya igalelo-umz., usebenzisa <input type="reset">
okanye ngokwenza ngesandla checked
ipropathi yegalelo-kuya kufuneka uguqule .active
ngokuzenzela <label>
.
Qaphela ukuba amaqhosha atshekishwe kwangaphambili afuna ukuba wongeze ngokwenza .active
iklasi kwigalelo <label>
.
Iindlela
Indlela | Inkcazo |
---|---|
$().button('toggle') |
Itshintsha imeko yokutyhala. Inika iqhosha inkangeleko yokuba livuliwe. |
$().button('dispose') |
Itshabalalisa iqhosha lesiqalelo. |