Dropdowns zikyusibwakyusibwa, contextual overlays okulaga enkalala z'enkolagana n'ebirala. Zikolebwa nga zikwatagana ne Bootstrap dropdown JavaScript plugin erimu. Zikyusibwakyusibwa nga zinyiga, so si nga ziwuubaala; kino kusalawo kwa dizayini mu bugenderevu .
Dropdowns zizimbibwa ku tterekero ly’ebitabo ery’ekibiina eky’okusatu, Popper.js , ekiwa ekifo ekikyukakyuka n’okuzuula ekifo eky’okulaba. Kakasa nti ossaamu popper.min.js nga tonnaba kukola JavaScript ya Bootstrap oba kozesa bootstrap.bundle.min.js/ bootstrap.bundle.jserimu Popper.js. Popper.js tekozesebwa kuteeka dropdowns mu navbars wadde nga dynamic positioning tekyetaagisa.
Bw'oba ozimba JavaScript yaffe okuva ku nsibuko, kyetaagisautil.js .
Okutuuka ku bantu
Omutindo gwa WAI ARIArole="menu" gutegeeza widget entuufu , naye kino kyetongodde ku menu eziringa enkola ezitandikawo ebikolwa oba emirimu. Menyu za ARIA zisobola okubeeramu ebintu bya menu byokka, ebintu bya menu eby’akabokisi akalaga, ebintu bya menu bya button ya radio, ebibinja bya button za radio, ne sub-menus.
Ku luuyi olulala, ebigwa bya Bootstrap bikoleddwa okuba eby’enjawulo era nga bikozesebwa mu mbeera ez’enjawulo n’ensengeka z’obubonero. Okugeza, kisoboka okukola ebifo ebikka ebirimu ebiyingizibwa ebirala n’ebifuga foomu, gamba ng’ennimiro z’okunoonya oba foomu z’okuyingira. Olw'ensonga eno, Bootstrap tesuubira (oba okwongera mu ngeri ey'otoma) ekintu kyonna ku rolen'ebintu aria-ebyetaagisa ku menu za ARIA entuufu . Abawandiisi bajja kuba balina okussaamu ebifaananyi bino ebisingawo ebitongole bennyini.
Naye, Bootstrap eyongerako obuwagizi obuzimbibwamu ku nkolagana za menu ya keyboard ezisinga obungi eza bulijjo, gamba ng’obusobozi okutambula mu .dropdown-itembintu ssekinnoomu ng’okozesa ebisumuluzo bya cursor n’okuggalawo menu ESCn’ekisumuluzo.
Eby’okulabirako
Zinga toggle ya dropdown (button yo oba link yo) ne dropdown menu munda mu .dropdown, oba elementi endala elangirira position: relative;. Dropdowns zisobola okutandika okuva <a>oba <button>elements okusobola okutuukana obulungi ku byetaago byo ebiyinza okubaawo.
Butaamu emu
Single yonna .btnesobola okufuulibwa dropdown toggle nga waliwo enkyukakyuka mu markup. Laba engeri gy’oyinza okuziteeka ku nkola n’ebintu byombi <button>:
Mu ngeri y’emu, tonda split button dropdowns nga kumpi markup y’emu nga button emu dropdowns, naye nga kwogasse .dropdown-toggle-splitfor for proper spacing around the dropdown caret.
Tukozesa kiraasi eno ey’enjawulo okukendeeza ku horizontal paddingku buli ludda lwa caret ebitundu 25% n’okuggyawo margin-leftthat’s added for regular button dropdowns. Enkyukakyuka ezo ez’enjawulo zikuuma caret ng’eri wakati mu bbaatuuni eyawuddwamu era ziwa ekifo ky’okukuba eky’obunene obutuufu okumpi ne bbaatuuni enkulu.
Mu byafaayo ebirimu mu menu egwa wansi byali birina okuba enkolagana, naye ekyo tekikyali bwe kityo ku v4. Kati osobola okukozesa <button>elements mu dropdowns zo mu kifo kya <a>s yokka.
Osobola n'okukola ebintu ebitali bikwatagana ne .dropdown-item-text. Wulira nga oli waddembe okwongera sitayiro n'ebikozesebwa ebya custom CSS oba ebiwandiiko.
Nga bwekiba, menu egwa wansi eteekebwa mu ngeri ey’otoma 100% okuva waggulu ne ku ludda olwa kkono olwa muzadde waayo. Okwongera .dropdown-menu-rightku a .dropdown-menuku ddyo sengeka menu egwa wansi.
Emitwe gigulumivu! Dropdowns ziteekebwa mu kifo okwebaza Popper.js (okuggyako nga ziri mu navbar).
Okulaganya okuddamu
Bw’oba oyagala okukozesa okulaganya okuddamu, lemesa okuteeka mu kifo ekikyukakyuka ng’ogattako data-display="static"ekintu era okozese ebika by’enkyukakyuka eziddamu.
Okukwataganya ku ddyo menu egwa wansi n'ekifo ekiweereddwa oba ekinene, yongerako .dropdown-menu{-sm|-md|-lg|-xl}-right.
Okukwataganya ku kkono menu egwa wansi n'ekifo ekiweereddwa oba ekinene, yongera .dropdown-menu-rightne .dropdown-menu{-sm|-md|-lg|-xl}-left.
Weetegereze nti teweetaaga kwongerako kintu data-display="static"ku buttons ezikka mu navbars, okuva Popper.js bwetakozesebwa mu navbars.
Ebirimu mu menu
Emitwe gy’omutwe
Okwongerako omutwe okuwandiika ebitundu by'ebikolwa mu menu yonna ekka.
Okuyita mu data attributes oba JavaScript, dropdown plugin ekyusa ebirimu ebikwekebwa (dropdown menus) nga ekyusa .showclass ku kintu ky'olukalala lw'omuzadde. Attribute data-toggle="dropdown"yesigamyeko okuggalawo dropdown menus ku ddaala ly'enkola, kale kirungi bulijjo okugikozesa.
Ku byuma ebisobola okukwata, okuggulawo ekintu ekigwa wansi kwongera ebikwaso ebyereere ( $.noop) mouseoverku baana ab’amangu <body>ab’ekintu. This admittedly ugly hack is necessary to work around a quirk in iOS' event delegation , ekiyinza okulemesa tap wonna ebweru w'okugwa okuva ku kutandika koodi eggalawo okugwa. Ekifo ekikka wansi bwe kimala okuggalwa, ebikwaso bino ebirala ebitaliiko kintu kyonna mouseoverbiggyibwawo.
Okuyita mu bikwata ku data
Yongera data-toggle="dropdown"ku link oba button okukyusa dropdown.
Okuyita mu JavaScript
Kuba ku bigenda okukka wansi ng’oyita mu JavaScript:
data-toggle="dropdown"kikyali kyetaagisa
Nga tofuddeeyo oba oyita dropdown yo ng'oyita mu JavaScript oba mu kifo ky'ekyo okozesa data-api, data-toggle="dropdown"bulijjo kyetaagisa okubeerawo ku dropdown's trigger element.
Eby’okulondako
Ebyokulonda bisobola okuyisibwa nga biyita mu data attributes oba JavaScript. Ku bikwata ku data, ssaako erinnya ly'okulonda ku data-, nga mu data-offset="".
Erinnya
Okuwandiika
Okukosamu
Okunnyonnyola
offset
ennamba | olunyiriri | enkola
0.
Offset ya dropdown okusinziira ku target yaayo.
Omulimu bwe gukozesebwa okuzuula offset, guyitibwa n’ekintu ekirimu data ya offset nga ensonga yaakyo esooka. Omulimu gulina okuzzaayo ekintu ekirina ensengeka y’emu. Ekintu ekivaako DOM node kiyisibwa nga ensonga eyokubiri.
Okumanya ebisingawo laba Popper.js's offset docs .
okukyuusa
boolean
kituufu
Kiriza Dropdown okufuumuuka mu mbeera y'okukwatagana ku elementi y'okujuliza. Okumanya ebisingawo laba Popper.js's flip docs .
ensalo
olunyiriri | ekintu
'omuzadde omuzingo'.
Ensalosalo y'okuziyiza okujjula eya menu egwa wansi. Ekkiriza emiwendo gya 'viewport', 'window', 'scrollParent', oba ekijuliziddwa HTMLElement (JavaScript yokka). Okumanya ebisingawo laba Popper.js's preventOverflow docs .
okwebuuza ewalala
olunyiriri | ekintu
'okukyusakyusa'.
Ekintu ekijuliziddwa mu menu egwa wansi. Akkiriza emiwendo gya 'toggle', 'parent', oba ekijuliziddwa HTMLElement. Okumanya ebisingawo laba Popper.js's referenceObject docs .
okulaga
akaguwa
'dynamic'.
Nga bwekiba, tukozesa Popper.js ku kifo ekikyukakyuka. Kino lemesa nga olina static.