Juyawa mai rufin mahallin mahallin don nuna jerin hanyoyin haɗin gwiwa da ƙari tare da kayan aikin saukar da Bootstrap.
Dubawa
Zazzage-zazzage ana iya jujjuyawa, mai rufin mahallin don nuna jerin hanyoyin haɗin kai da ƙari. An yi su da ma'amala tare da abubuwan da aka haɗa Bootstrap dropdown JavaScript plugin. Ana kunna su ta dannawa, ba ta shawagi ba; wannan yanke shawara ne da gangan .
An gina abubuwan saukarwa akan ɗakin karatu na ɓangare na uku, Popper.js , wanda ke ba da matsayi mai ƙarfi da gano wurin kallo. Tabbatar kun haɗa popper.min.js kafin Bootstrap's JavaScript ko amfani bootstrap.bundle.min.js/ bootstrap.bundle.jswanda ya ƙunshi Popper.js. Ba a amfani da Popper.js don sanya jerin abubuwan da aka saukar a cikin navbars kodayake ba a buƙatar matsayi mai ƙarfi.
Idan kuna gina JavaScript ɗin mu daga tushe, yana buƙatarutil.js .
Dama
Ma'auni na WAI ARIA yana bayyana ainihin role="menu"widget din , amma wannan ya keɓance ga menus-kamar aikace-aikace waɗanda ke haifar da ayyuka ko ayyuka. Menu na ARIA zai iya ƙunsar abubuwan menu kawai, abubuwan menu na akwati, abubuwan menu na maɓallin rediyo, ƙungiyoyin maɓallin rediyo, da ƙananan menus.
Bootstrap's dropdowns, a gefe guda, an ƙirƙira su don zama na yau da kullun kuma ana amfani da su ga yanayi iri-iri da tsarin saɓani. Misali, yana yiwuwa a ƙirƙiri zazzagewa waɗanda ke ƙunshe da ƙarin bayanai da sarrafawa, kamar filayen bincike ko fom ɗin shiga. Saboda wannan dalili, Bootstrap baya tsammanin (ko ƙara ta atomatik) kowane ɗayan roleda aria-halayen da ake buƙata don menu na ARIA na gaskiya. Marubuta dole ne su haɗa waɗannan ƙarin takamaiman halaye da kansu.
Koyaya, Bootstrap yana ƙara ginanniyar goyon baya don yawancin ma'amalar menu na maɓalli na yau da kullun, kamar ikon motsawa ta hanyar .dropdown-itemabubuwa ɗaya ta amfani da maɓallan siginan kwamfuta kuma rufe menu tare da ESCmaɓalli.
Misalai
Kunna maɓallin zazzagewa (maɓallin ku ko hanyar haɗin yanar gizonku) da menu na zaɓuka a cikin .dropdown, ko wani abin da ke bayyana position: relative;. Za a iya jawo saukar saukarwa daga <a>ko <button>abubuwa don dacewa da yuwuwar bukatun ku.
Maɓalli guda ɗaya
.btnAna iya jujjuya kowane guda ɗaya zuwa juzu'in zazzagewa tare da wasu canje-canje masu alama. Ga yadda zaku iya sanya su aiki tare da kowane <button>abu:
Hakazalika, ƙirƙiri maballin tsagawa tare da kusan alama iri ɗaya kamar maɓalli guda ɗaya, amma tare da ƙari .dropdown-toggle-splitdon tazarar da ta dace a kusa da wurin zaɓuka.
Muna amfani da wannan ƙarin ajin don rage kwance paddinga kowane gefe na kulawa da kashi 25% kuma cire margin-leftabin da aka ƙara don maɓalli na yau da kullun. Waɗannan ƙarin canje-canje suna kiyaye kulawar a tsakiya a cikin maɓallin tsaga kuma suna ba da mafi girman yanki mai girman da ya dace kusa da babban maɓallin.
Abubuwan menu na zaɓuka na tarihi dole ne su zama hanyoyin haɗin gwiwa, amma wannan ba haka yake ba tare da v4. Yanzu zaku iya amfani <button>da abubuwan da aka zaɓa a cikin jerin abubuwan da kuke so maimakon kawai <a>s.
Hakanan zaka iya ƙirƙirar abubuwan zazzage abubuwan da ba sa hulɗa tare da .dropdown-item-text. Jin kyauta don ƙara salo tare da CSS na al'ada ko kayan aikin rubutu.
Ta hanyar tsoho, menu na zaɓuka ana sanya shi ta atomatik 100% daga sama da gefen hagu na iyayensa. Ƙara .dropdown-menu-rightzuwa .dropdown-menudama a daidaita menu na zazzagewa.
A kula! Ana ajiye saukar saukar da godiya ga Popper.js (sai dai lokacin da suke cikin navbar).
Daidaitawa mai amsawa
Idan kana son amfani da jeri mai amsawa, musaki matsayi mai ƙarfi ta ƙara data-display="static"sifa kuma yi amfani da azuzuwan bambance-bambancen amsa.
Don daidaita menu na zazzage dama.dropdown-menu{-sm|-md|-lg|-xl}-right tare da wurin da aka bayar ko mafi girma, ƙara .
Don daidaita menu na zazzage hagu.dropdown-menu-right tare da wurin da aka bayar ko mafi girma, ƙara da .dropdown-menu{-sm|-md|-lg|-xl}-left.
Lura cewa ba kwa buƙatar ƙara data-display="static"sifa zuwa maɓallan zaɓuka a cikin navbars, tunda ba a amfani da Popper.js a navbars.
Menu abun ciki
Shugabanni
Ƙara taken zuwa lakabin sassan ayyuka a kowane menu na zazzagewa.
Sanya kowane rubutu na kyauta a cikin menu na zazzage tare da rubutu kuma yi amfani da abubuwan amfani tazara . Lura cewa ƙila za ku buƙaci ƙarin salon ƙima don takura faɗin menu.
Wani misali rubutu wanda ke gudana kyauta a cikin menu na zazzagewa.
Kuma wannan shine ƙarin misali rubutu.
Siffofin
Saka fom a cikin menu na zazzage, ko sanya shi cikin menu na zaɓuka, kuma yi amfani da gefe ko abubuwan amfani don ba shi mummunan sarari da kuke buƙata.
Ta hanyar sifofin bayanai ko JavaScript, zazzage plugin ɗin yana jujjuya abun ciki na ɓoye (menun zazzagewa) ta hanyar jujjuya .showaji akan abin jerin iyaye. An data-toggle="dropdown"dogara da sifa don rufe menu na zazzagewa a matakin aikace-aikace, don haka yana da kyau a yi amfani da shi koyaushe.
A kan na'urorin da aka kunna taɓawa, buɗe zazzagewa yana ƙara masu amfani da komai ( $.noop) mouseoverzuwa ga yaran abubuwan nan kusa <body>. Wannan admittedly mummuna hack wajibi ne don aiki a kusa da wani quirk a iOS' taron wakilan , wanda in ba haka ba zai hana wani famfo a ko'ina a waje da dropdown daga jawo da code cewa rufe jerin zaɓuka. Da zarar an rufe mouseoverzazzagewar, ana cire waɗannan ƙarin masu sarrafa fanko.
Ta hanyar bayanan halayen
Ƙara data-toggle="dropdown"zuwa hanyar haɗi ko maɓalli don kunna zazzagewa.
Ta hanyar JavaScript
Kira zazzagewar ta hanyar JavaScript:
data-toggle="dropdown"har yanzu ake bukata
Ko da kun kira zazzagewar ku ta JavaScript ko kuma a maimakon haka amfani da data-api, data-toggle="dropdown"ana buƙatar koyaushe don kasancewa akan abubuwan faɗakarwa.
Zabuka
Za a iya wucewa ta hanyar sifofin bayanai ko JavaScript. Don halayen bayanai, saka sunan zaɓin zuwa data-, kamar a cikin data-offset="".
Suna
Nau'in
Default
Bayani
biya diyya
lamba | zaren | aiki
0
Matsakaicin zazzagewa dangane da manufar sa.
Lokacin da aka yi amfani da aiki don tantance abin da aka kashe, ana kiran shi da wani abu mai ɗauke da bayanan kashewa azaman hujja ta farko. Dole ne aikin ya dawo da abu mai tsari iri ɗaya. An wuce kullin DOM mai jawowa azaman hujja ta biyu.
Don ƙarin bayani koma zuwa Popper.js's offset docs .
juya
boolean
gaskiya
Ba da izinin saukarwa don jujjuya idan akwai abin da ya faru a kan abin da ake tunani. Don ƙarin bayani koma zuwa Popper.js's lip docs .
iyaka
zaren | kashi
' gungurawaParent'
Matsakaicin ƙaƙƙarfan ƙayyadaddun iyaka na menu na zazzagewa. Yana karɓar ƙimar 'viewport', 'window', 'scrollParent', ko ma'anar HTMLElement (JavaScript kawai). Don ƙarin bayani koma zuwa Popper.js's preventoverflow docs .
tunani
zaren | kashi
'juyawa'
Abubuwan da ake bi na menu na zazzagewa. Yana yarda da ƙimar 'toggle', 'parent', ko bayanin HTMLElement. Don ƙarin bayani koma zuwa Popper.js's referenceObject docs .
nuni
kirtani
'tsari mai ƙarfi'
Ta hanyar tsoho, muna amfani da Popper.js don matsayi mai ƙarfi. Kashe wannan tare da static.
popperConfig
null | abu
banza
Don canza saitunan Popper.js na Bootstrap, duba saitin Popper.js
Lura lokacin da boundaryaka saita zuwa kowace ƙima banda 'scrollParent', position: staticana amfani da salon a cikin .dropdownakwati.
Hanyoyin
Hanya
Bayani
$().dropdown('toggle')
Yana jujjuya menu na zaɓuka na mashigar kewayawa da aka bayar ko kewayawa da aka buga.
$().dropdown('show')
Yana nuna menu na zazzagewa na mashigin kewayawa da aka bayar ko kewayawa ta shafi.
$().dropdown('hide')
Yana ɓoye menu na zaɓuka na mashigar kewayawa da aka bayar ko kewayawa da aka buga.
$().dropdown('update')
Yana sabunta matsayin zazzagewar kashi.
$().dropdown('dispose')
Yana lalata abubuwan zazzagewa.
Abubuwan da suka faru
Duk abubuwan da suka faru na zazzage ana harba su ne a .dropdown-menuɓangaren mahaifa kuma suna da relatedTargetkadarori, wanda ƙimar sa shine juzu'in anka. hide.bs.dropdownkuma hidden.bs.dropdownabubuwan da suka faru suna da clickEventdukiya (kawai lokacin da ainihin nau'in taron shine click) wanda ya ƙunshi Abun Abubuwan da ke faruwa don taron dannawa.
Lamarin
Bayani
show.bs.dropdown
Wannan taron yana gobara nan da nan lokacin da aka kira hanyar misalin nuni.
shown.bs.dropdown
Ana korar wannan taron lokacin da aka bayyana zazzagewa ga mai amfani (zai jira canjin CSS, don kammala).
hide.bs.dropdown
Ana korar wannan taron nan da nan lokacin da aka kira hanyar misalin ɓoye.
hidden.bs.dropdown
Ana korar wannan taron lokacin da jerin abubuwan da aka gama ɓoye daga mai amfani (zai jira canjin CSS, don kammala).