Di-dropdown tša go theoga
Fetoša dikhupetšo tša diteng bakeng sa go bontšha mananeo a dikgokagano le tše dingwe ka polaka ya go theoga ya Bootstrap.
Kakaretšo
Di-dropdown di ka fetošwa, di-overlay tša diteng tša go bontšha mananeo a dikgokagano le tše dingwe. Di dirilwe gore di be le tirišano ka plugin ya JavaScript ya go theoga ya Bootstrap yeo e akareditšwego. Di fetošwa ka go kgotla, e sego ka go hovering; ye ke phetho ya go hlama yeo e dirilwego ka boomo .
Di-dropdown di agilwe godimo ga bokgobapuku bja mokgatlo wa boraro, Popper , yeo e fago maemo a go fetoga le go utolla lefelo la go lebelela. Kgonthišetša gore o akaretša popper.min.js pele ga JavaScript ya Bootstrap goba o diriša bootstrap.bundle.min.js
/ bootstrap.bundle.js
yeo e nago le Popper. Popper ga e šomišwe go bea di-dropdown ka gare ga di-navbar le ge e le go beakanya mo go fetogago go sa nyakege.
Phihlelelo
The WAI ARIA standard defines an actual role="menu"
widget , eupša se se itšego go dimenu tša go swana le tirišo tšeo di hlohleletšago ditiro goba mešomo. Dimenu tša ARIA di ka ba le fela diaetheme tša thepo, diaetheme tša thepo ya lepokisi la go hlahloba, diaetheme tša thepo ya konope ya radio, dihlopha tša dikonope tša radio, le dimenu tša ka fasana.
Di-dropdown tša Bootstrap, ka lehlakoreng le lengwe, di hlamilwe go ba tša kakaretšo le go šoma maemong a fapa-fapanego le dibopego tša go swaya. Go fa mohlala, go a kgonega go hlama dithepo te di theogago te di nago le ditseno ta tlaleleto le ditaolo ta diforomo, go swana le mafelo a go nyaka goba diforomo ta go tsena. Ka lebaka le, Bootstrap ga e letele (goba go oketša ka go iketla) efe goba efe ya role
le aria-
dika tše di nyakegago bakeng sa dimenu tša nnete tša ARIA . Bangwadi ba tla swanelwa ke go akaretša dika tše tše di lebanyago kudu ka bobona.
Le ge go le bjalo, Bootstrap e tlaleletša thekgo ye e agetšwego ka gare ya bontši bja ditirišano tša thepo ya khiiboto ya maemo, go swana le bokgoni bja go sepela ka .dropdown-item
dielemente ka botee ka go šomiša dinotlelo tša khesara le go tswalela thepo ka ESCsenotlelo.
Mehlala
Phuthelela toggle ya go theoga (konope ya gago goba kgokagano) le thepo ya go theoga ka gare ga .dropdown
, goba elemente ye nngwe yeo e tsebagatšago position: relative;
. Di-dropdown di ka hlohleletša go tšwa <a>
goba <button>
dielemente go swanela gakaone dinyakwa tša gago tšeo di ka bago gona. Mehlala ye e bontšhitšwego mo e šomiša <ul>
dielemente tša semantiki moo go swanetšego, eupša go swaya ga tlwaelo go a thekgwa.
Konopo e le nngwe
Sefe goba sefe se tee se .btn
ka fetošetšwa go toggle ya go theoga ka diphetogo tše dingwe tša go swaya. Ke kamoo o ka di beago ka gona go šoma ka <button>
dielemente tše dingwe le tše dingwe:
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown button
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</div>
Le ka <a>
dielemente:
<div class="dropdown">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown link
</a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</div>
Karolo e kaone ke gore o ka dira se ka mohuta ofe goba ofe wa konope, le wena:
<!-- Example single danger button -->
<div class="btn-group">
<button type="button" class="btn btn-danger dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
Action
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</div>
Arola konopo
Ka mo go swanago, hlama di-dropdown tša konope ya go arogana ka go nyakile go swana le go swaya mo go swanago le go theoga ga konope e tee, eupša ka tlaleletšo ya .dropdown-toggle-split
bakeng sa sekgoba se se swanetšego go dikologa caret ya go theoga.
Re diriša sehlopha se sa tlaleletšo go fokotša go rapalala padding
ka mahlakoreng ka bobedi a caret ka 25% le go tloša margin-left
seo se okeditšwego bakeng sa di-dropdown tša konope tša ka mehla. Diphetogo tšeo tše oketšegilego di boloka caret e tsepame konotswaneng yeo e arotšwego gomme e nea lefelo la go otla leo le nago le bogolo bjo bo swanetšego kudu kgaufsi le konotswana e kgolo.
<!-- Example split danger button -->
<div class="btn-group">
<button type="button" class="btn btn-danger">Action</button>
<button type="button" class="btn btn-danger dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
<span class="visually-hidden">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</div>
Go lekanyetša bogolo
Dikonope tša go theoga di šoma ka dikonope tša bogolo ka moka, go akaretšwa dikonope tša go theoga tša go se fetoge le tša go arogana.
<!-- Large button groups (default and split) -->
<div class="btn-group">
<button class="btn btn-secondary btn-lg dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
Large button
</button>
<ul class="dropdown-menu">
...
</ul>
</div>
<div class="btn-group">
<button class="btn btn-secondary btn-lg" type="button">
Large split button
</button>
<button type="button" class="btn btn-lg btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
<span class="visually-hidden">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
...
</ul>
</div>
<div class="btn-group">
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
Small button
</button>
<ul class="dropdown-menu">
...
</ul>
</div>
<div class="btn-group">
<button class="btn btn-secondary btn-sm" type="button">
Small split button
</button>
<button type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
<span class="visually-hidden">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
...
</ul>
</div>
Di-dropdown tše lefsifsi
Kgetha go dithepo tša go theoga tše lefsifsi go swana le navbar ye lefsifsi goba setaele sa tlwaelo ka go tlaleletša .dropdown-menu-dark
godimo ga ye e lego gona .dropdown-menu
. Ga go na diphetogo tše di nyakegago go diaetheme tša go theoga.
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton2" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown button
</button>
<ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="dropdownMenuButton2">
<li><a class="dropdown-item active" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</div>
Gomme go e bea go šomiša ka gare ga navbar:
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDarkDropdown" aria-controls="navbarNavDarkDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDarkDropdown">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDarkDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</a>
<ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="navbarDarkDropdownMenuLink">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
Ditaelo
RTL e le
Directions ba seiponeng ha sebelisa Bootstrap ka RTL, ho bolela .dropstart
tla hlaha ka lehlakoreng le letona.
Dropup ya go lahlela
Hlohleletša dimenu tša go theoga ka godimo ga dielemente ka go tlaleletša .dropup
go elemente ya motswadi.
<!-- Default dropup button -->
<div class="btn-group dropup">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
Dropup
</button>
<ul class="dropdown-menu">
<!-- Dropdown menu links -->
</ul>
</div>
<!-- Split dropup button -->
<div class="btn-group dropup">
<button type="button" class="btn btn-secondary">
Split dropup
</button>
<button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
<span class="visually-hidden">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<!-- Dropdown menu links -->
</ul>
</div>
Tokelo ya go theoga
Hlohleletša dimenu tša go theoga ka go le letona la dielemente ka go tlaleletša .dropend
go elemente ya motswadi.
<!-- Default dropend button -->
<div class="btn-group dropend">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
Dropright
</button>
<ul class="dropdown-menu">
<!-- Dropdown menu links -->
</ul>
</div>
<!-- Split dropend button -->
<div class="btn-group dropend">
<button type="button" class="btn btn-secondary">
Split dropend
</button>
<button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
<span class="visually-hidden">Toggle Dropright</span>
</button>
<ul class="dropdown-menu">
<!-- Dropdown menu links -->
</ul>
</div>
Dropleft ya go theoga
Hlohleletša dimenu tša go theoga ka go la nngele la dielemente ka go tlaleletša .dropstart
go elemente ya motswadi.
<!-- Default dropstart button -->
<div class="btn-group dropstart">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
Dropstart
</button>
<ul class="dropdown-menu">
<!-- Dropdown menu links -->
</ul>
</div>
<!-- Split dropstart button -->
<div class="btn-group">
<div class="btn-group dropstart" role="group">
<button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
<span class="visually-hidden">Toggle Dropstart</span>
</button>
<ul class="dropdown-menu">
<!-- Dropdown menu links -->
</ul>
</div>
<button type="button" class="btn btn-secondary">
Split dropstart
</button>
</div>
Diaetheme tša menu
O ka šomiša <a>
goba <button>
dielemente bjalo ka diaetheme tša go theoga.
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
<li><button class="dropdown-item" type="button">Action</button></li>
<li><button class="dropdown-item" type="button">Another action</button></li>
<li><button class="dropdown-item" type="button">Something else here</button></li>
</ul>
</div>
O ka hlama gape diaetheme tša go theoga tšeo e sego tša tirišano ka .dropdown-item-text
. Ikwe o lokologile go setaele go ya pele ka CSS ya tlwaelo goba didirišwa tša sengwalwa.
<ul class="dropdown-menu">
<li><span class="dropdown-item-text">Dropdown item text</span></li>
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
Mafolofolo
Oketša .active
go diaetheme ka go theoga go di setaele bjalo ka tše di šomago . Go fetišetša boemo bjo bo šomago go theknolotši ya go thuša, šomiša aria-current
seka — o šomiša page
boleng bja letlakala la bjale, goba true
bakeng sa selo sa bjale ka seteng.
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Regular link</a></li>
<li><a class="dropdown-item active" href="#" aria-current="true">Active link</a></li>
<li><a class="dropdown-item" href="#">Another link</a></li>
</ul>
Šitišitšwe
Oketša .disabled
go diaetheme ka go theoga go di setaele bjalo ka tše di golofetšego .
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Regular link</a></li>
<li><a class="dropdown-item disabled" href="#" tabindex="-1" aria-disabled="true">Disabled link</a></li>
<li><a class="dropdown-item" href="#">Another link</a></li>
</ul>
Go logaganya menu
Ka go ikemela, thepo ya go theoga e bewa ka go iketla 100% go tšwa godimo le go bapa le lehlakore la nngele la motswadi wa yona. O ka fetola se ka .drop*
diklase ta tlhahlo, eupa o ka di laola gape ka diklase ta tlaleleto ta sefetoledi.
Oketša .dropdown-menu-end
go a go ya .dropdown-menu
go le letona logaganya thepo ya go theoga. Directions ba seiponeng ha sebelisa Bootstrap ka RTL, ho bolela .dropdown-menu-end
tla hlaha ka lehlakoreng le letšehali.
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
Right-aligned menu example
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li><button class="dropdown-item" type="button">Action</button></li>
<li><button class="dropdown-item" type="button">Another action</button></li>
<li><button class="dropdown-item" type="button">Something else here</button></li>
</ul>
</div>
Go logaganya mo go arabelago
Ge o nyaka go šomiša go logaganya ga go arabela, šitiša go beakanya ga go fetoga ka go oketša data-bs-display="static"
seka gomme o šomiše diklase tša phapano ya go arabela.
Go logaganya ka go le letona thepo ya go theoga le ntlha ya go kgaotša ye e filwego goba ye kgolo, oketša .dropdown-menu{-sm|-md|-lg|-xl|-xxl}-end
.
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" data-bs-display="static" aria-expanded="false">
Left-aligned but right aligned when large screen
</button>
<ul class="dropdown-menu dropdown-menu-lg-end">
<li><button class="dropdown-item" type="button">Action</button></li>
<li><button class="dropdown-item" type="button">Another action</button></li>
<li><button class="dropdown-item" type="button">Something else here</button></li>
</ul>
</div>
Go logaganya thepo ya go theoga ya nngele.dropdown-menu-end
le ntlha ya go kgaotša ye e filwego goba ye kgolo, oketša le .dropdown-menu{-sm|-md|-lg|-xl|-xxl}-start
.
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" data-bs-display="static" aria-expanded="false">
Right-aligned but left aligned when large screen
</button>
<ul class="dropdown-menu dropdown-menu-end dropdown-menu-lg-start">
<li><button class="dropdown-item" type="button">Action</button></li>
<li><button class="dropdown-item" type="button">Another action</button></li>
<li><button class="dropdown-item" type="button">Something else here</button></li>
</ul>
</div>
Hlokomela gore ga o hloke go oketša data-bs-display="static"
seka go dikonope tša go theoga ka go di-navbar, ka ge Popper e sa šomišwe ka go di-navbar.
Dikgetho tša go logaganya
Ho nka boholo ba dikgetho bontšitsoeng ka holimo, mona ke e nyenyane kichineng nwelela demo ya fapaneng dropdown lolamisiwa ga dikgetho sebakeng se le seng.
<div class="btn-group">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
</ul>
</div>
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
Right-aligned menu
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
</ul>
</div>
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" data-bs-display="static" aria-expanded="false">
Left-aligned, right-aligned lg
</button>
<ul class="dropdown-menu dropdown-menu-lg-end">
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
</ul>
</div>
<div class="btn-group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" data-bs-display="static" aria-expanded="false">
Right-aligned, left-aligned lg
</button>
<ul class="dropdown-menu dropdown-menu-end dropdown-menu-lg-start">
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
</ul>
</div>
<div class="btn-group dropstart">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
Dropstart
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
</ul>
</div>
<div class="btn-group dropend">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
Dropend
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
</ul>
</div>
<div class="btn-group dropup">
<button type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
Dropup
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
</ul>
</div>
Diteng tša menu
Dihlogo tša dihlogo
Oketša hlogo go leina dikarolo tša ditiro ka go thepo efe goba efe ya go theoga.
<ul class="dropdown-menu">
<li><h6 class="dropdown-header">Dropdown header</h6></li>
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
</ul>
Dikaroganyo
Aroganya dihlopha tša dintho tša menu tše di amanago ka karoganyo.
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
Sengwalwa
Bea sengwalwa sefe goba sefe sa sebopego sa go se lefelwe ka gare ga thepo ya go theoga ka sengwalwa gomme o šomiše didirišwa tša sekgoba . Hlokomela gore go na le kgonagalo ya gore o tla nyaka mekgwa ya tlaleletšo ya go lekanyetša bogolo go thibela bophara bja thepo.
<div class="dropdown-menu p-4 text-muted" style="max-width: 200px;">
<p>
Some example text that's free-flowing within the dropdown menu.
</p>
<p class="mb-0">
And this is more example text.
</p>
</div>
Diforomo
Bea foromo ka gare ga thepo ya go theoga, goba o e dire gore e be thepo ya go theoga, gomme o šomiše didirišwa tša ka thoko goba tša go tlatša go e fa sekgoba se sebe seo o se nyakago.
<div class="dropdown-menu">
<form class="px-4 py-3">
<div class="mb-3">
<label for="exampleDropdownFormEmail1" class="form-label">Email address</label>
<input type="email" class="form-control" id="exampleDropdownFormEmail1" placeholder="[email protected]">
</div>
<div class="mb-3">
<label for="exampleDropdownFormPassword1" class="form-label">Password</label>
<input type="password" class="form-control" id="exampleDropdownFormPassword1" placeholder="Password">
</div>
<div class="mb-3">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="dropdownCheck">
<label class="form-check-label" for="dropdownCheck">
Remember me
</label>
</div>
</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="mb-3">
<label for="exampleDropdownFormEmail2" class="form-label">Email address</label>
<input type="email" class="form-control" id="exampleDropdownFormEmail2" placeholder="[email protected]">
</div>
<div class="mb-3">
<label for="exampleDropdownFormPassword2" class="form-label">Password</label>
<input type="password" class="form-control" id="exampleDropdownFormPassword2" placeholder="Password">
</div>
<div class="mb-3">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="dropdownCheck2">
<label class="form-check-label" for="dropdownCheck2">
Remember me
</label>
</div>
</div>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>
Dikgetho tša go theoga
Šomiša data-bs-offset
goba data-bs-reference
go fetoša lefelo la go theoga.
<div class="d-flex">
<div class="dropdown me-1">
<button type="button" class="btn btn-secondary dropdown-toggle" id="dropdownMenuOffset" data-bs-toggle="dropdown" aria-expanded="false" data-bs-offset="10,20">
Offset
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuOffset">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</div>
<div class="btn-group">
<button type="button" class="btn btn-secondary">Reference</button>
<button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" id="dropdownMenuReference" data-bs-toggle="dropdown" aria-expanded="false" data-bs-reference="parent">
<span class="visually-hidden">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuReference">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</div>
</div>
Auto koala boitšoaro
Ka go ikemela, thepo ya go theoga e a tswalelwa ge o klika ka gare goba ka ntle ga thepo ya go theoga. O ka šomiša autoClose
kgetho go fetoša boitshwaro bjo bja go theoga.
<div class="btn-group">
<button class="btn btn-secondary dropdown-toggle" type="button" id="defaultDropdown" data-bs-toggle="dropdown" data-bs-auto-close="true" aria-expanded="false">
Default dropdown
</button>
<ul class="dropdown-menu" aria-labelledby="defaultDropdown">
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
</ul>
</div>
<div class="btn-group">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuClickableOutside" data-bs-toggle="dropdown" data-bs-auto-close="inside" aria-expanded="false">
Clickable outside
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuClickableOutside">
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
</ul>
</div>
<div class="btn-group">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuClickableInside" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
Clickable inside
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuClickableInside">
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
</ul>
</div>
<div class="btn-group">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuClickable" data-bs-toggle="dropdown" data-bs-auto-close="false" aria-expanded="false">
Manual close
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuClickable">
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
<li><a class="dropdown-item" href="#">Menu item</a></li>
</ul>
</div>
Sass
Diphetogo
Diphetogo tša go theoga ka moka:
$dropdown-min-width: 10rem;
$dropdown-padding-x: 0;
$dropdown-padding-y: .5rem;
$dropdown-spacer: .125rem;
$dropdown-font-size: $font-size-base;
$dropdown-color: $body-color;
$dropdown-bg: $white;
$dropdown-border-color: rgba($black, .15);
$dropdown-border-radius: $border-radius;
$dropdown-border-width: $border-width;
$dropdown-inner-border-radius: subtract($dropdown-border-radius, $dropdown-border-width);
$dropdown-divider-bg: $dropdown-border-color;
$dropdown-divider-margin-y: $spacer * .5;
$dropdown-box-shadow: $box-shadow;
$dropdown-link-color: $gray-900;
$dropdown-link-hover-color: shade-color($gray-900, 10%);
$dropdown-link-hover-bg: $gray-200;
$dropdown-link-active-color: $component-active-color;
$dropdown-link-active-bg: $component-active-bg;
$dropdown-link-disabled-color: $gray-500;
$dropdown-item-padding-y: $spacer * .25;
$dropdown-item-padding-x: $spacer;
$dropdown-header-color: $gray-600;
$dropdown-header-padding: $dropdown-padding-y $dropdown-item-padding-x;
Diphetogo bakeng sa dropdown e lefifi : .
$dropdown-dark-color: $gray-300;
$dropdown-dark-bg: $gray-800;
$dropdown-dark-border-color: $dropdown-border-color;
$dropdown-dark-divider-bg: $dropdown-divider-bg;
$dropdown-dark-box-shadow: null;
$dropdown-dark-link-color: $dropdown-dark-color;
$dropdown-dark-link-hover-color: $white;
$dropdown-dark-link-hover-bg: rgba($white, .15);
$dropdown-dark-link-active-color: $dropdown-link-active-color;
$dropdown-dark-link-active-bg: $dropdown-link-active-bg;
$dropdown-dark-link-disabled-color: $gray-500;
$dropdown-dark-header-color: $gray-500;
Diphetogo tša di-caret tše di theilwego go CSS tšeo di laetšago tirišano ya go theoga:
$caret-width: .3em;
$caret-vertical-align: $caret-width * .85;
$caret-spacing: $caret-width * .85;
Ditswaki
Di- mixin di šomišwa go tšweletša di- caret tše di theilwego go CSS gomme di ka hwetšwa go scss/mixins/_caret.scss
.
@mixin caret-down {
border-top: $caret-width solid;
border-right: $caret-width solid transparent;
border-bottom: 0;
border-left: $caret-width solid transparent;
}
@mixin caret-up {
border-top: 0;
border-right: $caret-width solid transparent;
border-bottom: $caret-width solid;
border-left: $caret-width solid transparent;
}
@mixin caret-end {
border-top: $caret-width solid transparent;
border-right: 0;
border-bottom: $caret-width solid transparent;
border-left: $caret-width solid;
}
@mixin caret-start {
border-top: $caret-width solid transparent;
border-right: $caret-width solid;
border-bottom: $caret-width solid transparent;
}
@mixin caret($direction: down) {
@if $enable-caret {
&::after {
display: inline-block;
margin-left: $caret-spacing;
vertical-align: $caret-vertical-align;
content: "";
@if $direction == down {
@include caret-down();
} @else if $direction == up {
@include caret-up();
} @else if $direction == end {
@include caret-end();
}
}
@if $direction == start {
&::after {
display: none;
}
&::before {
display: inline-block;
margin-right: $caret-spacing;
vertical-align: $caret-vertical-align;
content: "";
@include caret-start();
}
}
&:empty::after {
margin-left: 0;
}
}
}
Tšhomišo
Ka dika tša datha goba JavaScript, polaka ya go theoga e fetoša diteng tše di utilwego (dimenu tša go theoga) ka go fetoša .show
sehlopha go motswadi .dropdown-menu
. Sebopego data-bs-toggle="dropdown"
se ithekgile ka go tswalela dimenu tša go theoga maemong a tirišo, ka fao ke kgopolo ye botse go se šomiša ka mehla.
mouseover
ditshwaro tše di se nago selo go bana ba kgauswi ba
<body>
elemente. This admittedly ugly hack is necessary to work around a
quirk in iOS’ event delegation , e leng ka tsela e nngwe e ne e tla thibela pompo kae kapa kae ka ntle ho dropdown ho qholotsa khoutu e koala dropdown. Ge go šetše go tswaletšwe, didirišwa tše tša tlaleletšo tše di se nago selo
mouseover
di a tlošwa.
Ka dika ya data
Oketša data-bs-toggle="dropdown"
go kgokagano goba konope go fetoša go theoga.
<div class="dropdown">
<button id="dLabel" type="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown trigger
</button>
<ul class="dropdown-menu" aria-labelledby="dLabel">
...
</ul>
</div>
Ka JavaScript
Bitša di-drolodown ka JavaScript:
var dropdownElementList = [].slice.call(document.querySelectorAll('.dropdown-toggle'))
var dropdownList = dropdownElementList.map(function (dropdownToggleEl) {
return new bootstrap.Dropdown(dropdownToggleEl)
})
data-bs-toggle="dropdown"
e sa dutše e nyakega
Go sa šetšwe gore o bitša dropdown ya gago ka JavaScript goba go e na le moo o diriša data-api, data-bs-toggle="dropdown"
go nyakega ka mehla go ba gona go elemente ya go hlohleletša ya dropdown.
Dikgetho
Dikgetho di ka fetišwa ka dika tša datha goba JavaScript. Bakeng sa dika tša datha, tlaleletša leina la kgetho go data-bs-
, bjalo ka go data-bs-offset=""
. Kgonthiša gore o fetoša mohuta wa molato wa leina la kgetho go tšwa go camelCase go ya go kebab-case ge o fetiša dikgetho ka dika tša datha. Ka mohlala, go e na le go diriša data-bs-autoClose="false"
, diriša data-bs-auto-close="false"
.
Leina | Mohuta | Hlokomologa | Tlhalošo |
---|---|---|---|
boundary |
thapo ya | ntlha | 'clippingParents' |
Moedi wa thibelo ya go tlala wa thepo ya go theoga (e šoma fela go sefetoši sa preventOverflow sa Popper). Ka go ikemela ke 'clippingParents' gomme e ka amogela tšhupetšo ya HTMLElement (ka JavaScript fela). Bakeng sa tshedimošo ye ntši lebelela ditokomane tša detectOverflow tša Popper . |
reference |
thapo ya | elemente | selo | 'toggle' |
Reference elements ya menu ya go theoga. E amogela dikelo tša 'toggle' , 'parent' , tšhupetšo ya HTMLElement goba selo seo se fago getBoundingClientRect . Bakeng sa tshedimošo ye ntši lebelela ditokomane tša moagi tša Popper le ditokomane tša elemente ya go bonagala . |
display |
thapo | 'dynamic' |
Ka default, re sebelisa Popper bakeng sa boemo ba mafolofolo. Thibela se ka static . |
offset |
array | thapo ya | mošomo | [0, 2] |
Offset ya dropdown leloko le sepheo lona. O ka fetiša thapo ka go dika tša datha ka boleng bjo bo arotšwego ka koma go swana le: Ge mošomo o šomišwa go laetša offset, o bitšwa ka selo seo se nago le go bewa ga popper, tšhupetšo, le popper rects bjalo ka ngangišano ya yona ya mathomo. The qholotsa elements DOM noutu e fetisoa e le ngangišano ya bobedi. Mošomo o swanetše go bušetša lenaneo leo le nago le dinomoro tše pedi: . Bakeng sa tshedimošo ye ntši lebelela ditokomane tša offset tša Popper . |
autoClose |
boolean ya | thapo | true |
Beakanya boitšoaro ba auto koala ya dropdown:
|
popperConfig |
lefeela | selo sa | mošomo | null |
Go fetoša peakanyo ya Popper ya maitirelo ya Bootstrap, bona peakanyo ya Popper . Ge mošomo o šomišwa go hlama peakanyo ya Popper, e bitšwa ka selo seo se nago le peakanyo ya Popper ya maitirelo ya Bootstrap. E go thuša go šomiša le go kopanya ya go se fetoge le peakanyo ya gago. Mošomo o swanetše go bušetša selo sa peakanyo sa Popper. |
Go šomiša mošomo kapopperConfig
var dropdown = new bootstrap.Dropdown(element, {
popperConfig: function (defaultBsPopperConfig) {
// var newPopperConfig = {...}
// use defaultBsPopperConfig if needed...
// return newPopperConfig
}
})
Mekgwa ya go šoma
Mokgwa | Tlhalošo |
---|---|
toggle |
E fetola thepo ya go theoga ya navbar ye e filwego goba go sepelasepela ga dithepo. |
show |
E bontšha thepo ya go theoga ya navbar ye e filwego goba go sepelasepela ka dithepo. |
hide |
E uta thepo ya go theoga ya navbar ye e filwego goba go sepelasepela ga dithepo. |
update |
E mpshafatša maemo a go theoga ga elemente. |
dispose |
E senya go theoga ga elemente. (E tloša ya data ye e bolokilwego go elemente ya DOM) |
getInstance |
Mokgwa wa go se fetoge wo o go dumelelago go hwetša mohlala wa go theoga wo o amanago le elemente ya DOM, o ka e šomiša ka tsela ye:bootstrap.Dropdown.getInstance(element) |
getOrCreateInstance |
Mokgwa wa go se fetoge wo o bušetšago mohlala wa go theoga wo o amanago le elemente ya DOM goba go hlama ye mpsha ge go ka direga gore e se ya thongwa. O ka e diriša ka tsela ye:bootstrap.Dropdown.getOrCreateInstance(element) |
Ditiragalo
Ditiragalo ka moka tša go theoga di thuntšhwa go elemente ya go fetoša gomme ka morago tša bubbled godimo. Ka fao o ka oketša gape le batheeletši ba tiragalo godimo ga .dropdown-menu
elemente ya motswadi ya '. hide.bs.dropdown
gomme hidden.bs.dropdown
ditiragalo di na le clickEvent
thepa (feela ge mohuta wa mathomo wa Tiragalo e le click
) yeo e nago le Selo sa Tiragalo sa tiragalo ya go klika.
Mokgwa | Tlhalošo |
---|---|
show.bs.dropdown |
E thunya ka pela ge mokgwa wa mohlala wa pontšho o bitšwa. |
shown.bs.dropdown |
E thuntšhwa ge go theoga go dirilwe gore go bonagale go modiriši gomme diphetogo tša CSS di phethilwe. |
hide.bs.dropdown |
E thunya ka pela ge mokgwa wa go uta mohlala o biditšwe. |
hidden.bs.dropdown |
E thuntšhwa ge go theoga go feditše go utollwa go tšwa go modiriši gomme diphetogo tša CSS di phethilwe. |
var myDropdown = document.getElementById('myDropdown')
myDropdown.addEventListener('show.bs.dropdown', function () {
// do something...
})