Dropdowns kan jedhu
Tarreewwan hidhannoo fi kanneen biroo agarsiisuuf haguuggii haalata jijjiiri, tarreewwan tarree Bootstrap waliin.
Kubbaawwan jijjiiramuu danda'u, tarreewwan hidhannoowwanii fi kkf agarsiisuuf haguuggii haalata. Isaanis Bootstrap dropdown JavaScript plugin dabalameen walqunnamtii akka ta'an taasifamaniiru. Isaan kan toggled cuqaasuun malee hovering gochuudhaan miti; kun murtoo dizaayinii itti yaadanii kennameedha.
Dropdowns mana kitaabaa qaama sadaffaa irratti ijaaramaniiru, Popper.js , kunis bakka daayinamikii fi adda baasuu iddoo ilaalchaa kenna. JaavaScript Bootstrap dura popper.min.js dabaluu kee mirkaneessi ykn bootstrap.bundle.min.js
/ bootstrap.bundle.js
kan Popper.js of keessaa qabu fayyadami. Popper.js navbars keessatti gadi bu'iinsa iddoo kaa'uuf hin fayyadamu haa ta'u malee akka iddoo daayinamikii hin barbaachifnetti.
Yoo JavaScriptutil.js
keenya madda irraa ijaaraa jirta ta'e, .
Istaandardiin WAI ARIArole="menu"
wiijetii qabatamaa ibsa , garuu kun menuwwan aplikeeshinii fakkaatanii kanneen gochoota ykn dalagaalee kakaasan adda ta'a. Sajoo ARIA wanta sajoo, wanta sajoo sanduuqa filannoo, wanta sajoo qaree raadiyoo, gareewwan qaree raadiyoo, fi sajoo xiqqaa qofa qabaachuu danda'u.
Bootstrap's dropdowns, gama biraatiin, akka waliigalaa fi haalawwan adda addaa fi caasaa mallattoo irratti hojiirra ooluu danda'aniif qophaa'aniiru. Fakkeenyaaf, tarreewwan galtee dabalataa fi too'annoo unkaa of keessaa qaban uumuun ni danda'ama, kan akka man'ee barbaacha ykn unka galmee. Sababa kanaaf, Bootstrap amaloota role
fi menuwwan ARIAaria-
dhugaatiif barbaachisan kamiyyuu hin eegu (ofumaanis hin dabalu). Barreessitoonni amaloota adda ta’an kana ofuma isaanii hammachuu qabu.
Haa ta'u malee, Bootstrap walqunnamtii menu furtuu istaandaardii baay'eedhaaf deeggarsa ijaarame dabalata, kan akka dandeettii .dropdown-item
furtuuwwan qaree fayyadamuun elementoota dhuunfaa keessa socho'uu fi furtuun menu cufuu ESC.
Jijjiirraa tarree (qaree ykn hidhaa kee) fi sajoo tarree keessaa .dropdown
, ykn qaama biraa kan labsu marsi position: relative;
. Dropdowns irraa <a>
ykn <button>
elementoota fedhii kee ta'uu danda'u haala gaariin walsimuuf kakaafamuu danda'a.
Tokkichi kamiyyuu .btn
gara jijjiirama mallattoo tokko tokkoon gara jijjiirraa gadi-bu'aa jijjiiramuu danda'a. <button>
Akkaataa isaan elementoota lamaanuu wajjin hojiitti galchuu dandeessu kunooti :
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown button
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
Akkasumas <a>
elementoota waliin:
<div class="dropdown show">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown link
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
Kutaan hundarra gaariin kana gochuu dandeessa button variant kamiinuu, akkasumas:
Haaluma walfakkaatuun, tarreewwan qaree qoqqoodaman kanneen mallattoo walfakkaataa ta'an kanneen qaree tokkoo wajjin wal fakkaatu uumi, garuu .dropdown-toggle-split
naannoo caret gadi bu'aa addaan fageenya sirrii ta'eef dabaluudhaan.
Gitaa dabalataa kana fayyadamnee horizontal padding
gama lamaanuu caret %25 hir'isuu fi margin-left
that's added for regular button dropdowns balleessuuf. Jijjiiramni dabalataa sun caret qaree addaan ba'e keessatti giddugaleessa akka ta'ee fi bakka rukuttaa safara sirrii ta'e qaree guddaa cinatti kenna.
Tarreewwan qaree qaree hammangaa hunda waliin hojjetu, qaree durtii fi qoodame dabalatee.
.dropup
Qaaqa warraa irratti dabaluudhaan qaaqawwan tarree qaamolee olitti kakaasi .
.dropright
Qaaqa warraa irratti dabaluudhaan sajoo tarree mirgaa qaamolee irratti kakaasi .
.dropleft
Qaaqa warraa irratti dabaluudhaan sajoo tarree bitaa qaamolee irratti kakaasi .
Seenaa keessatti qabiyyeen menu gadi bu'aa hidhaa ta'uu qaba ture , garuu kana booda v4 irratti akkas miti. Amma filannoodhaan <button>
elementoota tarreewwan kee keessatti <a>
s qofa osoo hin taane fayyadamuu dandeessa.
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenu2">
<button class="dropdown-item" type="button">Action</button>
<button class="dropdown-item" type="button">Another action</button>
<button class="dropdown-item" type="button">Something else here</button>
</div>
</div>
Akka durtiitti, sajoo tarree ofumaan 100% gubbaa irraa fi gama bitaa warra isaa irratti dhaabbata. Sajoo tarree gara mirgaatti .dropdown-menu-right
dabali ..dropdown-menu
Mataa ol qaba! Dropdowns galata Popper.js (yeroo navbar keessatti qabaman malee) bakka bu'u.
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Right-aligned menu
</button>
<div class="dropdown-menu dropdown-menu-right">
<button class="dropdown-item" type="button">Action</button>
<button class="dropdown-item" type="button">Another action</button>
<button class="dropdown-item" type="button">Something else here</button>
</div>
</div>
Kutaalee gochaalee sajoo tarree kamiyyuu keessatti asxaa gochuuf mataduree dabali.
<div class="dropdown-menu">
<h6 class="dropdown-header">Dropdown header</h6>
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
</div>
Garee wanta menu walqabatan qoqqoodduu waliin addaan baasi.
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Separated link</a>
</div>
Unkaa sajoo tarree keessa kaa'i, ykn gara sajoo gadi bu'aa godhi, fi faayidaa margina ykn padding fayyadamii iddoo negaatiivii barbaaddu kenniif.
<div class="dropdown-menu">
<form class="px-4 py-3">
<div class="form-group">
<label for="exampleDropdownFormEmail1">Email address</label>
<input type="email" class="form-control" id="exampleDropdownFormEmail1" placeholder="[email protected]">
</div>
<div class="form-group">
<label for="exampleDropdownFormPassword1">Password</label>
<input type="password" class="form-control" id="exampleDropdownFormPassword1" placeholder="Password">
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="dropdownCheck">
<label class="form-check-label" for="dropdownCheck">
Remember me
</label>
</div>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">New around here? Sign up</a>
<a class="dropdown-item" href="#">Forgot password?</a>
</div>
<form class="dropdown-menu p-4">
<div class="form-group">
<label for="exampleDropdownFormEmail2">Email address</label>
<input type="email" class="form-control" id="exampleDropdownFormEmail2" placeholder="[email protected]">
</div>
<div class="form-group">
<label for="exampleDropdownFormPassword2">Password</label>
<input type="password" class="form-control" id="exampleDropdownFormPassword2" placeholder="Password">
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="dropdownCheck2">
<label class="form-check-label" for="dropdownCheck2">
Remember me
</label>
</div>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>
.active
Wantoota tarree keessa jiranitti dabali akka socho'aa ta'etti akkaataa itti gootu .
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Regular link</a>
<a class="dropdown-item active" href="#">Active link</a>
<a class="dropdown-item" href="#">Another link</a>
</div>
.disabled
Wantoota akka hanqifameetti akkaataa itti godhuuf tarree keessa jiranitti dabali .
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Regular link</a>
<a class="dropdown-item disabled" href="#">Disabled link</a>
<a class="dropdown-item" href="#">Another link</a>
</div>
Karaa amaloota deetaa ykn JaavaScript, ifteessituun tarree qabiyyee dhokataa (qajoojiiwwan gadi bu'aa) .show
gita wanta tarree warraa irratti jijjiiruun jijjiira. Amalli kun data-toggle="dropdown"
sadarkaa aplikeeshinii irratti qaaqawwan gadi bu'aa cufuuf irratti hirkata, kanaaf yeroo hunda fayyadamuun yaada gaarii dha.
Meeshaalee tuqaan dandeessifaman irratti, tarree banuun qabattoota duwwaa ( $.noop
) mouseover
ijoollee dhiyeenya <body>
elementichaatti dabalata. This admittedly ugly hack is necessary to work around a quirk in iOS' event delegation , kunis yoo kana hin taane tuquun bakka kamittiyyuu gadi bu'iinsaan ala ta'e koodii gadi bu'aa cufu akka hin kakaasne dhorka ture. Erga gadi bu'iinsi cufamee booda, mouseover
qabattoonni duwwaa dabalataa kun ni haqamu.
data-toggle="dropdown"
Tarree tokko jijjiiruuf hidhaa ykn qaree irratti dabali .
Karaa JaavaScript kanneen gadi bu'an bilbili:
data-toggle="dropdown"
ammallee barbaachisaadha
Karaa JaavaScript tarree kee waamtus ykn inumaayyuu data-api fayyadamuu kee osoo hin ilaalin, data-toggle="dropdown"
yeroo hunda elementii kaka'umsaa gadi bu'aa irratti argamuun barbaachisaadha.
Filannoon karaa amaloota deetaa ykn JaavaScript darbuu danda'u. Amaloota deetaatiif, maqaa filannoo gara data-
, akkuma keessatti dabali data-offset=""
.
Maqaa | Akaakuu | Durtii dha | Ibsa |
---|---|---|---|
ofseeti jechuun ni danda’ama | lakkoofsa | tarree | faayidaa | 0. | Ofseeti kufaatii galma isaa wajjin walqabatee. Odeeffannoo dabalataaf Popper.js's offset docs ilaali . |
garagalchuu | boolee | dhugaa | Yoo qaama wabii irratti wal-irra bu'e, Gadi-bu'aan akka garagalchu hayyami. Odeeffannoo dabalataaf Popper.js's flip docs ilaali . |
daangaa | tarree | qabiyyee | 'Warra garagalchuu'. | Daangaa danqaa dhangala'aa sajoo tarree gadi bu'aa. Gatii 'viewport' , 'window' , 'scrollParent' , ykn wabii HTMLElement fudhata (JavaScript qofa). Odeeffannoo dabalataaf Popper.js's preventOverflow docs ilaali . |
Hubadhu yeroo boundary
gatii kamiyyuu irratti qindaa'u 'scrollParent'
, akkaataan qabduu position: static
irratti hojii irra oola ..dropdown
Mala | Ibsa |
---|---|
$().dropdown('toggle') |
Sajoo tarree navbar kennamee ykn qajeelcha caancalaa jijjiira. |
$().dropdown('update') |
Bakka tarree qaama tokkoo fooyyessa. |
$().dropdown('dispose') |
Tarree elementii tokkoo balleessa. |
Taateewwan gadi bu'aa hundi .dropdown-menu
qaama warraa 's irratti dhukaafamu fi relatedTarget
qabeentaa qabu, kan gatiin isaa qaama anchor jijjiirraa dha.
Taatee | Ibsa |
---|---|
show.bs.dropdown |
Taatee kun yeroo mala fakkeenya agarsiisaa waamamu battalumatti dhukaasa. |
shown.bs.dropdown |
Taatee kun yeroo gadi bu'iinsi fayyadamaaf akka mul'atu godhame ni ari'ama (ce'umsa CSS ni eega, xumuruuf). |
hide.bs.dropdown |
Taatee kun yeroo mala fakkeenya dhoksaa waamame battalumatti dhukaafama. |
hidden.bs.dropdown |
Taatee kun kan dhukaafamu yeroo gadi bu'iinsi fayyadamaa irraa dhokfamuu xumure (ce'umsa CSS ni eega, xumuruuf). |