Iingcebiso
Amaxwebhu kunye nemizekelo yokongeza iingcebiso zesiko le-Bootstrap ngeCSS kunye neJavaScript usebenzisa i-CSS3 yoopopayi kunye neempawu zedatha zogcino lwesihloko sendawo.
Isishwankathelo
Izinto omawuzazi xa usebenzisa iplagi yesixhobo se-tooltip:
- Iingcebiso zezixhobo zixhomekeke kwithala leencwadi le-3rd Popper.js ngokubekwa . Kufuneka ubandakanye i -popper.min.js phambi kwe-bootstrap.js okanye usebenzise
bootstrap.bundle.min.js
/bootstrap.bundle.js
equlethe i-Popper.js ukuze izixhobo zokusebenza zisebenze! - Ukuba wakha iJavaScript yethu kwimvelaphi, kufuna
util.js
. - Iingcebiso zezixhobo zingenile ngenxa yezizathu zokusebenza, ke kufuneka uziqalise ngokwakho .
- Iingcebiso zezixhobo ezinezihloko ezibude buziro aziboniswa.
- Cacisa
container: 'body'
ukunqanda unikezelo lweengxaki kumacandelo antsokothileyo (njengamaqela ethu egalelo, amaqela amaqhosha, njl.njl). - Iingcebiso zokuqalisa kwizinto ezifihlakeleyo aziyi kusebenza.
- Iingcebiso zesixhobo
.disabled
okanyedisabled
izakhi kufuneka zivuswe kuphawu lokusonga. - Xa iqaliswa ukusuka kwiihyperlink ezithatha imigca emininzi, iincam zesixhobo ziya kugxilwa. Sebenzisa
white-space: nowrap;
kwi yakho<a>
ukunqanda le ukuziphatha. - Iingcebiso kufuneka zifihlwe phambi kokuba izinto ezihambelanayo nazo zisuswe kwiDOM.
- Iingcebiso zesixhobo zinokuqhutywa enkosi kwinto engaphakathi kwesithunzi se-DOM.
Isiphumo soopopayi seli candelo sixhomekeke prefers-reduced-motion
kumbuzo wemidiya. Jonga icandelo leentshukumo ezincitshisiweyo kuxwebhu lwethu lofikelelo .
Unayo yonke loo nto? Kulungile, makhe sibone ukuba basebenza njani ngemizekelo ethile.
Umzekelo: Vumela iingcebiso zesixhobo kuyo yonke indawo
Enye indlela yokuqalisa zonke iingcebiso zesixhobo kwiphepha inokuba kukukhetha ngophawu lwazo data-toggle
:
Imizekelo
Hambisa ngaphezulu kwezi linki zingezantsi ukuze ubone iingcebiso zesixhobo:
Iibhulukhwe eziqinileyo kwinqanaba elilandelayo keffiyeh mhlawumbi awuzange uve ngazo. Photo booth iindevu ekrwada idenim letterpress vegan messenger bag stumptown. Ifama-to-itheyibhile seitan, i-mcsweeney's fixie ezinzileyo iquinoa ye-8-bit yaseMelika isambatho sine - terry richardson vinyl chambray. Iindevu stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. Igcisa elihlekisayo ngokwenene whatever keytar , i-scenar farm-to-table banksy Austin twitter handle freegan cred krwada idenim enye-origin ikofu viral.
Hambisa phezu kwamaqhosha angezantsi ukuze ubone izalathiso zezixhobo ezine: phezulu, ekunene, ezantsi, nasekhohlo.
Kwaye nge-HTML yesiko elongeziweyo:
Ukusetyenziswa
Isixhobo se-plugin se-tooltip sivelisa umxholo kunye ne-markup kwimfuno, kwaye ngokungagqibekanga iindawo zeengcebiso zesixhobo emva kwento yazo ye-trigger.
Qalisa ingcebiso yesixhobo ngeJavaScript:
Ukuphuphuma auto
kwayescroll
Indawo yengcebiso yesixhobo izama ukuzitshintsha ngokuzenzekelayo xa isikhongozeli somzali sinaso overflow: auto
okanye overflow: scroll
sisithanda .table-responsive
, kodwa sigcina indawo ebekuyo yokuqala. Ukusombulula, seta boundary
ukhetho kuyo nayiphi na enye into ngaphandle kwexabiso elingagqibekanga, 'scrollParent'
elinje 'window'
:
IMarkup
Uphawu olufunekayo lwencam yesixhobo luphawu kuphela data
kwaye title
kwisiqalelo se-HTML unqwenela ukuba nencam yesixhobo. Uphawu oluveliswayo lwencam yesixhobo lulula, nangona lufuna indawo (ngokungagqibekanga, top
lumiselwe yiplagi).
Ukwenza iingcebiso zesixhobo zisebenzele ikhibhodi kunye nabasebenzisi betekhnoloji abancedisayo
Kufuneka wongeze kuphela iingcebiso zesixhobo kwizinto ze-HTML ngokwesiko zekhibhodi-ejolise kwaye isebenze (ezifana namakhonkco okanye ulawulo lwefom). Nangona izinto ze-HTML ezingenamkhethe (ezinje nge- <span>
s) zinokwenziwa ziqwalaselwe ngokongeza tabindex="0"
uphawu, oku kuyakongeza ukumisa okunokucaphukisa kunye nokubhidanisa ithebhu kwizinto ezingasebenzisaniyo kubasebenzisi bebhodi yezitshixo, kwaye uninzi lwetekhnoloji encedisayo ngoku ayazisi inqaku lesixhobo kule meko. Ukongeza, ungathembeli kuphela hover
njengesixhobo sesixhobo sakho, njengoko oku kuya kwenza ukuba izixhobo zakho zesixhobo zingenzeki ukuqalisa kubasebenzisi bebhodi yezitshixo.
Izinto ezikhubazekileyo
Izinto disabled
ezinophawu azisebenzi, nto leyo ethetha ukuba abasebenzisi abanakugxila, bashukume, okanye bacofe ukuze baqalise ingcebiso yesixhobo (okanye ipopover). Njengendlela yokusebenza, uya kufuna ukuvusa inqaku lesixhobo ukusuka kwisisongelo <div>
okanye <span>
, eyenziwe ngokufanelekileyo ikhibhodi-ijolise ekusebenziseni tabindex="0"
, kwaye ubhale ngaphezulu pointer-events
kwinto ekhubazekileyo.
Iinketho
Iinketho zinokugqithiswa ngeempawu zedatha okanye iJavaScript. Kuphawu lwedatha, faka igama lokhetho ku data-
, njengakwi data-animation=""
.
Qaphela ukuba ngenxa yezizathu zokhuseleko sanitize
, sanitizeFn
kwaye whiteList
iinketho azikwazi kunikezelwa kusetyenziswa iimpawu zedata.
Igama | Uhlobo | Ukuhlala kukho | Inkcazo |
---|---|---|---|
oopopayi | boolean | yinyani | Faka inguqu ye-CSS fade kwi-tooltip |
isikhongozeli | umtya | into | bubuxoki | bubuxoki | Ihlomela incam yesixhobo kwinto ethile. Umzekelo: |
ukulibazisa | inombolo | into | 0 | Ukulibazisa ukubonisa kunye nokufihla isixhobo sesixhobo (ms) - akusebenzi kuhlobo lwesixhobo sokuxhobisa Ukuba inani linikiwe, ukulibaziseka kufakwa kuzo zombini ezifihla/umboniso Ulwakhiwo lwento yile: |
html | boolean | bubuxoki | Vumela i-HTML kwincam yesixhobo. Ukuba yinyaniso, iithegi ze-HTML kwincam yesixhobo Sebenzisa umbhalo ukuba unexhala malunga nohlaselo lwe-XSS. |
ukubekwa | umtya | umsebenzi | 'phezulu' | Uyibeka njani incam yesixhobo - auto | phezulu | emazantsi | ekhohlo | kunene. Xa umsebenzi usetyenziswa ukumisela ukubekwa, ubizwa ngokuba nencam yesixhobo ye-DOM njengengxoxo yayo yokuqala kunye nesiqalo se-DOM node njengesibini sayo. Umxholo |
umkhethi | umtya | bubuxoki | bubuxoki | Ukuba umkhethi unikiwe, izixhobo zesixhobo ziya kunikezelwa kwiithagethi ezichaziweyo. Ngokwesiqhelo, oku kusetyenziselwa ukusebenzisa iingcebiso zesixhobo kwizinto ezongeziweyo zeDOM ( jQuery.on inkxaso). Bona oku kunye nomzekelo ofundisayo . |
ithempleyithi | umtya | '<div class="tooltip" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>' |
Isiseko se-HTML esiza kusetyenziswa xa usenza ithiphu yesixhobo. Isixhobo se-tooltip
Isiqalelo sokusonga sangaphandle kufuneka sibe |
isihloko | umtya | into | umsebenzi | '' | Ixabiso lesihloko esihlala sihleli ukuba Ukuba umsebenzi unikiwe, uya kubizwa kunye |
ukuxhokonxa | umtya | 'hover focus' | Ivuswa njani ithiphu yesixhobo - cofa | jonga | gxila | incwadi yesandla. Ungadlula ezininzi izichukumisi; bahlule ngesithuba.
|
i-offset | inombolo | umtya | umsebenzi | 0 | Iseti yesixhobo esinxulumene noko kujoliswe kuko. Xa umsebenzi usetyenziselwa ukumisela i-offset, ubizwa ngento equlethe idatha ye-offset njengengxabano yayo yokuqala. Umsebenzi kufuneka ubuyisele into enesakhiwo esifanayo. Isiqalo se-DOM node sigqithiselwe njengengxoxo yesibini. Ngolwazi oluthe kratya jonga kwi-Popper.js's offset docs . |
i-fallbackPlacement | umtya | uluhlu | 'jika' | Vumela ukuxela ukuba yeyiphi indawo iPopper eza kusebenzisa xa ubuya umva. Ngolwazi oluthe vetshe bhekisa kuPopper.js's behaviour docs |
umda | umtya | isiqalelo | 'skrolaMzali' | Ukuphuphuma komda womda wesixhobo. Yamkela amaxabiso e- 'viewport' , 'window' , 'scrollParent' , okanye i-HTMLElement ireferensi (iJavaScript kuphela). Ngolwazi oluthe vetshe bhekisa kuPopper.js's preventOverflow docs . |
coceka | boolean | yinyani | Yenza okanye uvale ucoceko. Ukuba ivuliwe 'template' kwaye 'title' iinketho ziyakuhlanjululwa. |
Uluhlu olumhlophe | into | Ixabiso elimiselweyo | Into equlathe iimpawu ezivumelekileyo kunye neethegi |
sanizeFn | null | umsebenzi | null | Apha ungabonelela ngomsebenzi wakho wokucoca. Oku kunokuba luncedo ukuba ukhetha ukusebenzisa ithala leencwadi elizinikeleyo ukwenza ucoceko. |
popperConfig | null | into | null | Ukutshintsha uqwalaselo olungagqibekanga lweBootstrap lwePopper.js, bona uqwalaselo lwePopper.js |
Iimpawu zedatha kwiingcebiso zesixhobo ngasinye
Iinketho zeengcebiso zesixhobo ngasinye zinokuchazwa ngokusetyenziswa kweempawu zedatha, njengoko kucacisiwe ngasentla.
Iindlela
Iindlela ze-Asynchronous kunye notshintsho
Zonke iindlela ze-API zi -asynchronous kwaye ziqala utshintsho . Babuyela kumnxeba ngokukhawuleza nje ukuba utshintsho luqalisiwe kodwa ngaphambi kokuba luphele . Ukongeza, ukufowunelwa kwendlela kwicandelo lenguquko kuya kuhoywa .
$().tooltip(options)
Iqhoboshela isibambi sesixhobo kwingqokelela yesiqalelo.
.tooltip('show')
Ityhila inqaku lesixhobo. Ibuyisela kumnxebi phambi kokuba incam yesixhobo iboniswe (okt phambi kokuba shown.bs.tooltip
isiganeko senzeke). Oku kuthathwa ngokuba "yimanyuwali" yokuqalisa inqaku lesixhobo. Iingcebiso zezixhobo ezinezihloko ezibude buziro aziboniswa.
.tooltip('hide')
Ifihla incam yesixhobo. Ibuyisela kumnxeba phambi kokuba incam yesixhobo ifihliwe (okt phambi kokuba hidden.bs.tooltip
isiganeko senzeke). Oku kuthathwa ngokuba "yimanyuwali" yokuqalisa inqaku lesixhobo.
.tooltip('toggle')
Itshintshela incam yesixhobo. Ibuyisela kumnxebi phambi kokuba incam yesixhobo iboniswe okanye ifihlwe (okt phambi kokuba isiganeko shown.bs.tooltip
okanye hidden.bs.tooltip
isiganeko senzeke). Oku kuthathwa ngokuba "yimanyuwali" yokuqalisa inqaku lesixhobo.
.tooltip('dispose')
Ifihla kwaye itshabalalise isixhobo sesixhobo. Iingcebiso zesixhobo ezisebenzisa unikezelo (ezenziwe ngokusetyenziswa kokhethoselector
) azinakutshatyalaliswa zizodwa kwizinto ezibangela ukuvela .
.tooltip('enable')
Inika isixhobo sesixhobo sokukwazi ukuboniswa. Iingcebiso zesixhobo zenziwe ngokwendalo.
.tooltip('disable')
Isusa isakhono sesixhobo sesixhobo sokuboniswa. Ingcebiso yesixhobo iya kuboniswa kuphela ukuba yenziwe yasebenza kwakhona.
.tooltip('toggleEnabled')
Iguqula isakhono sesixhobo sesixhobo sokuboniswa okanye ukufihlwa.
.tooltip('update')
Ihlaziya indawo yesixhobo sesixhobo.
Iziganeko
Uhlobo loMnyhadala | Inkcazo |
---|---|
bonisa.bs.ingcebiso yesixhobo | Esi siganeko sivutha ngokukhawuleza xa show kubizwa indlela yomzekelo. |
ingcebiso.bs.isixhobo | Esi siganeko sigxothwa xa i-tooltip yenziwe yabonakala kumsebenzisi (iya kulinda iinguqu zeCSS ukuba zigqibe). |
fihla.bs.ingcebiso yesixhobo | Esi siganeko sigxothwa ngokukhawuleza xa hide indlela yomzekelo ibiziwe. |
ingcebiso.bs.isixhobo esifihliweyo | Esi siganeko siyagxothwa xa icebo lesixhobo ligqityiwe ukufihlwa kumsebenzisi (liya kulinda uguqulo lweCSS lugqibe). |
ingcebiso.bs.isixhobo | Esi siganeko sigxothwa emva show.bs.tooltip kwesiganeko xa ithemplate ye-tooltip yongezwa kwi-DOM. |