SourceIbitonyanga
Kuzuza ibice byuzuye kugirango werekane urutonde rwihuza nibindi hamwe na Bootstrap yamanutse.
Ibitonyanga birashobora guhindagurika, guhuza ibice kugirango werekane urutonde rwihuza nibindi byinshi. Bikorewe hamwe na Bootstrap yamanutse ya plagin ya JavaScript. Barahindurwa mukanda, ntabwo ari ukuzunguruka; iki nicyemezo cyo gushushanya nkana.
Ibitonyanga byubatswe kububiko bwibitabo byabandi, Popper.js , itanga umwanya uhagaze hamwe no kureba ibintu. Wemeze gushyiramo popper.min.js mbere ya JavaScript ya Bootstrap cyangwa ukoreshe bootstrap.bundle.min.js
/ bootstrap.bundle.js
irimo Popper.js. Popper.js ntabwo ikoreshwa mugushira ibitonyanga muri navbars nubwo nkibikorwa bya dinamike bidasabwa.
Niba wubaka JavaScript yacu kuva isoko, birasabautil.js
.
Igipimo cya WAI ARIA gisobanura role="menu"
widget ifatika , ariko ibi birihariye kubisabwa-nkibikubiyemo bitera ibikorwa cyangwa imikorere. Ibikubiyemo bya ARIA birashobora gusa kuba bikubiyemo ibintu, kugenzura agasanduku k'ibikubiyemo, ibintu bya radiyo buto ya menu, amatsinda ya buto ya radio, na sub-menus.
Ibitonyanga bya Bootstrap, kurundi ruhande, byashizweho kugirango bibe rusange kandi bikurikizwa mubihe bitandukanye no kuranga imiterere. Kurugero, birashoboka gukora ibitonyanga birimo inyongeramusaruro ninyongera kugenzura, nkibice byo gushakisha cyangwa ifishi yinjira. Kubwiyi mpamvu, Bootstrap ntabwo yiteze (cyangwa ihita yongeraho) icyaricyo cyose role
nibiranga aria-
ibisabwa kuri ARIA nyayo . Abanditsi bagomba gushyiramo ibi biranga byihariye ubwabo.
Ariko, Bootstrap yongeramo infashanyo yubufasha bwibisanzwe bya menu ya clavier, nkubushobozi bwo kunyura .dropdown-item
mubintu bitandukanye ukoresheje urufunguzo rwa indanga hanyuma ugafunga menu ESCnurufunguzo.
Kuzuza ibitonyanga byamanutse (buto yawe cyangwa ihuza) na menu yamanutse imbere .dropdown
, cyangwa ikindi kintu gitangaza position: relative;
. Ibitonyanga birashobora gukururwa bivuye <a>
cyangwa <button>
ibintu kugirango bihuze neza nibyo ukeneye.
Ikintu icyo aricyo cyose .btn
gishobora guhinduka kumanuka uhindagurika hamwe nibimenyetso byahindutse. Dore uburyo ushobora kubashyira mubikorwa hamwe <button>
nibintu:
Kandi hamwe <a>
nibintu:
Igice cyiza nuko ushobora kubikora ukoresheje buto iyo ariyo yose, nayo:
Mu buryo busa nabwo, kora ibice bitandukanya ibice byamanutse hamwe nikimenyetso kimwe kimwe na buto imwe yamanutse, ariko hamwe niyongerwaho .dropdown-toggle-split
ryumwanya ukwiye hafi yigitonyanga.
Dukoresha iri somo ryinyongera kugirango tugabanye horizontal padding
kumpande zombi za caret kuri 25% hanyuma dukureho margin-left
ibyo byongeweho kubisanzwe bya buto. Izo mpinduka zinyongera zituma caret yibanze muri bouton igabanijwe kandi igatanga ahantu hanini cyane hit hitabwa kuruhande rwa buto nkuru.
Utubuto tumanuka dukorana na buto yubunini bwose, harimo nibisanzwe no kugabanura ibitonyanga.
Imbarutso yamanutse iboneka hejuru yibintu wongeyeho .dropup
kubabyeyi.
Imbarutso yamanutse iboneka iburyo bwibintu wongeyeho .dropright
kubabyeyi.
Imbarutso yamanutse iboneka ibumoso bwibintu wongeyeho .dropleft
kubabyeyi.
Amateka yamanutse yibirimo yagombaga kuba amahuza, ariko ibyo ntibikiri kuri v4. Noneho urashobora guhitamo gukoresha <button>
ibintu mumanuka aho kuba <a>
s.
Urashobora kandi gukora ibintu bitagabanije kumanura ibintu hamwe .dropdown-item-text
. Wumve neza ko wuburyo bwiza hamwe na CSS yihariye cyangwa inyandiko zikoreshwa.
Ongeraho .active
mubintu biri kumanuka kugirango ubitondere nkibikorwa .
Ongeraho .disabled
mubintu biri kumanuka kugirango ubitondere nkuko byahagaritswe .
Mburabuzi, menu yamanutse ihita ishyirwa 100% uhereye hejuru no kuruhande rwibumoso rwababyeyi. Ongeraho iburyo .dropdown-menu-right
kugirango .dropdown-menu
uhuze menu yamanutse.
Umutwe! Ibitonyanga byashyizwe kumurongo dukesha Popper.js (usibye iyo bikubiye muri navbar).
Ongeraho umutwe kugirango ushireho ibice byibikorwa muri menu iyo ari yo yose.
Tandukanya amatsinda yibintu bifitanye isano nibice.
Shyira inyandiko iyariyo yose muri menu yamanutse hamwe ninyandiko hanyuma ukoreshe umwanya utandukanye . Menya ko ushobora gukenera inyongera zingana kugirango ubuze menu ubugari.
Shira ifishi muri menu yamanutse, cyangwa uyigire muri menu yamanutse, hanyuma ukoreshe margin cyangwa padding utanga kugirango uhe umwanya mubi ukeneye.
Koresha data-offset
cyangwa data-reference
uhindure ahantu hamanuka.
Binyuze muri data ibiranga cyangwa JavaScript, plugin yamanutse ihinduranya ibintu byihishe (ibimanuka byamanutse) muguhindura .show
icyiciro kurutonde rwababyeyi. Ikiranga data-toggle="dropdown"
gishingiye ku gufunga ibimanuka kurutonde rwa porogaramu, nibyiza rero guhora tuyikoresha.
Kubikoresho bifasha gukoraho, gufungura ibitonyanga byongeramo ubusa ( $.noop
) mouseover
imashini kubana bahita ba <body>
element. Ibi byemewe ko ari hack birakenewe kugirango dukore hafi yikinamico mu ntumwa za iOS , ibyo bikaba byabuza gukanda ahantu hose hanze y’igitonyanga gukurura code ifunga ibitonyanga. Iyo ibitonyanga bimaze gufungwa, ibyo byongeweho ubusa mouseover
bikurwaho.
Binyuze mu biranga amakuru
Ongeraho data-toggle="dropdown"
kumurongo cyangwa buto kugirango uhindure ibitonyanga.
Hamagara ibitonyanga ukoresheje JavaScript:
data-toggle="dropdown"
biracyasabwa
Utitaye ko wahamagaye ibitonyanga ukoresheje JavaScript cyangwa ugakoresha data-api, data-toggle="dropdown"
burigihe birasabwa kuba uhari kubintu byamanutse.
Amahitamo arashobora kunyuzwa kumurongo wamakuru cyangwa JavaScript. Kubiranga Ibyatanzwe, Ongeraho Izina Izina Kuri data-
, Nka Muri data-offset=""
.
Izina |
Andika |
Mburabuzi |
Ibisobanuro |
offset |
umubare | umugozi | imikorere |
0 |
Kureka kugabanuka ugereranije nintego yayo. Kubindi bisobanuro reba popper.js ya offset ya doc . |
flip |
boolean |
ni ukuri |
Emerera Ibitonyanga guhindagurika mugihe habayeho guhuzagurika kubintu bifatika. Kubindi bisobanuro reba flip docs ya Popper.js . |
imbibi |
umugozi | element |
'umuzingoParent' |
Kurenga imipaka imbibi za menu yamanutse. Emera indangagaciro za ,,, 'viewport' cyangwa HTMLElement yerekana (JavaScript gusa). Kubindi bisobanuro reba Popper.js yo gukumiraOverflow docs .'window' 'scrollParent' |
Indanganturo |
umugozi | element |
'guhinduranya' |
Ibikoresho byerekana ibintu byamanutse. Emera indangagaciro za 'toggle' ,, 'parent' cyangwa HTMLElement yerekana. Kubindi bisobanuro reba Popper.js yerekanaObject docs . |
Kugaragaza |
umugozi |
'imbaraga' |
Mburabuzi, dukoresha Popper.js kumwanya uhagaze. Hagarika ibi hamwe static . |
Icyitonderwa mugihe boundary
gishyizwe kumurongo uwo ariwo wose usibye 'scrollParent'
, imiterere position: static
ikoreshwa kuri .dropdown
kontineri.
Uburyo |
Ibisobanuro |
$().dropdown('toggle') |
Kuzuza menu yamanutse ya navbar yatanzwe cyangwa kugendagenda. |
$().dropdown('update') |
Kuvugurura umwanya wibintu byamanutse. |
$().dropdown('dispose') |
Gusenya ikintu cyamanutse. |
Ibintu byose byamanutse birasa kuri .dropdown-menu
'ababyeyi bababyeyi kandi bafite relatedTarget
umutungo, agaciro kabo ni uguhindura inanga. nibyabaye bifite hide.bs.dropdown
umutungo (gusa iyo ibyabaye byumwimerere ubwoko ni ) bikubiyemo ibyabaye kubintu byo gukanda ibyabaye.hidden.bs.dropdown
clickEvent
click
Icyabaye |
Ibisobanuro |
show.bs.dropdown |
Ibirori birasa ako kanya iyo kwerekana urugero uburyo bwitwa. |
shown.bs.dropdown |
Ibirori birukanwa mugihe ibitonyanga byakozwe kubakoresha (bizategereza inzibacyuho ya CSS, kugirango birangire). |
hide.bs.dropdown |
Ibi birori birahita bisohoka mugihe uburyo bwo guhisha bwahamagawe. |
hidden.bs.dropdown |
Ibirori birukanwa mugihe ibitonyanga byarangije guhishwa kubakoresha (bizategereza inzibacyuho ya CSS, kugirango birangire). |