Navs kple tabs
Nuŋlɔɖiwo kple kpɔɖeŋuwo na alesi woazã Bootstrap ƒe mɔfiame ƒe akpa siwo le eme.
Base nav
Navigation si li le Bootstrap me ma dzesi kple atsyãwo le xexeame katã, tso gɔmeɖoanyi .nav
ƒe klass dzi va ɖo nɔnɔme siwo le dɔ wɔm kple esiwo me nuwɔametɔ le dzi. Trɔ asi le tɔtrɔ ƒe hatsotsowo ŋu be nàtrɔ ɖe atsyã ɖesiaɖe dome.
Wotu gɔmeɖoanyi .nav
ƒe akpaa kple flexbox eye wònaa gɔmeɖoanyi sesẽ aɖe na mɔfiame ƒe akpa ƒomevi ɖesiaɖe tutu. Elɔ atsyã ƒe tɔtrɔ aɖewo ɖe eme (hena dɔwɔwɔ kple xexlẽdzesiwo), kadodo ƒe padding aɖewo na teƒe siwo lolo wu siwo woƒo, kple atsyã vevi siwo wowɔ le nuwɔametɔwo ŋu.
Gɔmeɖoanyi .nav
ƒe akpaa melɔ .active
nɔnɔme aɖeke ɖe eme o. Kpɔɖeŋu siwo gbɔna la lɔ klass la ɖe eme, vevietɔ be woaɖee afia be klass sia koŋ meʋãa atsyã tɔxɛ aɖeke o.
Be nàtsɔ nɔnɔme si le dɔ wɔm la ayi kpekpeɖeŋu mɔ̃ɖaŋunuwo gbɔ la, zã aria-current
nɔnɔmea — zã page
asixɔxɔ na axa si li fifia, alo true
na nu si li fifia le ƒuƒoƒo aɖe me.
<ul class="nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Wozãa klasswo katã, eyata wò markup ate ŋu anye super flexible. Zã <ul>
s abe alesi wòle etame ene, ne wò nuwo ƒe ɖoɖo le vevie, alo nàtsɔ element <ol>
aɖe aƒo tɔwò . <nav>
Elabena the .nav
uses display: flex
, nav kadodoawo wɔa nu abe alesi nav nuawo awɔ nui ene, gake dzesidede kpeɖeŋutɔa manɔmee.
<nav class="nav">
<a class="nav-link active" aria-current="page" href="#">Active</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled">Disabled</a>
</nav>
Atsyã siwo li
Trɔ .nav
s component ƒe atsyã kple modifiers kple utilities. Tsɔe tsaka eye nàtsɔe asɔ kple wo nɔewo ne ehiã, alo nàtu tɔwò.
Nusiwo woɖo ɖe ɖoɖo nu le tsia dzi
Trɔ wò nav ƒe ɖoɖo si le tsia dzi kple flexbox dɔwɔnuwo . Le gɔmedzedzea me la, navs le miame, gake àteŋu atrɔ wo bɔbɔe be woaɖo titina alo ɖusime.
Le titina kple .justify-content-center
:
<ul class="nav justify-content-center">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Woɖoe ɖe ɖusime kple .justify-content-end
:
<ul class="nav justify-content-end">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Tsi tsitre
Stack wò navigation to asitɔtrɔ le flex item ƒe mɔfiame kple .flex-column
utility la me. Ðe wòhiã be nàƒo wo nu ƒu ɖe nukpɔkpɔmɔ̃ aɖewo dzi gake menye ɖe bubuwo dzi oa? Zã gɔmeɖeɖe siwo ɖoa nya ŋu (le kpɔɖeŋu me, .flex-sm-column
).
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Abe alesi wònɔna ɖaa ene la, mɔzɔzɔ le tsitrenu ate ŋu adzɔ <ul>
s manɔmee, hã.
<nav class="nav flex-column">
<a class="nav-link active" aria-current="page" href="#">Active</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled">Disabled</a>
</nav>
Tabwo ƒe ƒuƒoƒo
Exɔa nav vevi la tso dziƒo eye wòtsɔa .nav-tabs
klass la kpena ɖe eŋu be wòawɔ tabbed interface. Zã wo nàtsɔ awɔ tabbable nutowo kple míaƒe tab JavaScript plugin .
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Atikekuiwo
Tsɔ HTML ma ke, gake zãe .nav-pills
boŋ:
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Kpe ɖo eye nàɖo kpe edzi
Zi wò .nav
's emenyawo dzi be woakeke kekeme bliboa si li la ɖe enu le tɔtrɔɖenu ƒe hatsotso eve dometɔ ɖeka me. .nav-item
Be nàtsɔ wò s ayɔ teƒe siwo katã li la ɖe ɖoɖo nu la, zã .nav-fill
. De dzesii be woxɔ teƒe siwo katã le tsia dzi, gake menye nav nu ɖesiaɖe ƒe kekeme sɔ o.
<ul class="nav nav-pills nav-fill">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Much longer nav link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Ne èle <nav>
mɔfiame si wotu ɖe -dzi zãm la, àte ŋu aɖe asi le eŋu dedie .nav-item
elabena ɖeko .nav-link
wòhiã na atsyã ƒe <a>
akpawo.
<nav class="nav nav-pills nav-fill">
<a class="nav-link active" aria-current="page" href="#">Active</a>
<a class="nav-link" href="#">Much longer nav link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled">Disabled</a>
</nav>
Ne èdi nusiwo ƒe kekeme sɔ la, zã .nav-justified
. Nav kadodowo axɔ teƒe siwo katã le tsia dzi, gake to vovo na esiwo le .nav-fill
etame la, nav nu ɖesiaɖe ƒe kekeme anɔ ɖeka.
<ul class="nav nav-pills nav-justified">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Much longer nav link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Abe .nav-fill
kpɔɖeŋu si wozã <nav>
-si wotu ɖe mɔfiame dzi ene.
<nav class="nav nav-pills nav-justified">
<a class="nav-link active" aria-current="page" href="#">Active</a>
<a class="nav-link" href="#">Much longer nav link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled">Disabled</a>
</nav>
Dɔwɔwɔ kple flex utilities
Ne èhiã nav tɔtrɔ siwo ɖoa nya ŋu la, bu flexbox dɔwɔnu siwo kplɔ wo nɔewo ɖo zazã ŋu . Togbɔ be nyagbɔgblɔ geɖe wu hã la, dɔwɔnu siawo naa asitɔtrɔ geɖe wu le breakpoints siwo ɖoa nya ŋu me. Le kpɔɖeŋu si le ete me la, míaƒe nav la aƒo ƒu ɖe gbagbãƒe si bɔbɔ wu dzi, emegbe woatrɔ ɖe ɖoɖo si le tsia dzi si ayɔ kekeme si li la me adze egɔme tso gbagbãƒe sue la dzi.
<nav class="nav nav-pills flex-column flex-sm-row">
<a class="flex-sm-fill text-sm-center nav-link active" aria-current="page" href="#">Active</a>
<a class="flex-sm-fill text-sm-center nav-link" href="#">Longer nav link</a>
<a class="flex-sm-fill text-sm-center nav-link" href="#">Link</a>
<a class="flex-sm-fill text-sm-center nav-link disabled">Disabled</a>
</nav>
Ku ɖe alesi woate ŋu aɖoe ŋu
Ne èle navs zãm tsɔ le mɔfiame ƒe ʋuƒo nam la, kpɔ egbɔ be yetsɔ a kpe role="navigation"
ɖe dzila ƒe nugoe si me susu le wu ŋu le <ul>
, alo nàxatsa nu <nav>
aɖe ɖe mɔfiame bliboa ŋu. Mègatsɔ akpaa akpe ɖe <ul>
eya ŋutɔ ŋu o, elabena esia axe mɔ na mɔ̃ɖaŋununya siwo kpena ɖe ame ŋu be woaɖe gbeƒãe be enye xexlẽdzesi ŋutɔŋutɔ o.
De dzesii be mele be woana mɔfiamewo, ne wowɔ wo le nukpɔkpɔ me abe tabwo kple .nav-tabs
klass la ene gɔ̃ hã la , , alo nɔnɔmewo o. Esiawo sɔ na dynamic tabbed interfaces ko, abe alesi woɖe eme le WAI ARIA Authoring Practices me ene. Kpɔ JavaScript ƒe nuwɔna na dynamic tabbed interfaces le akpa sia me hena kpɔɖeŋu. Nɔnɔmea mehiã le dynamic tabbed interfaces dzi o elabena míaƒe JavaScript kpɔa nɔnɔme si nètia la gbɔ to tsɔtsɔ kpe ɖe tab si le dɔ wɔm la dzi.role="tablist"
role="tab"
role="tabpanel"
aria-current
aria-selected="true"
Nusiwo wotsɔna ƒua gbe zazã
Tsɔ nu siwo le tsia dzi kple HTML vi aɖe kpee kple JavaScript ƒe kpeɖeŋutɔ siwo le tsia dzi la kpe ɖe eŋu .
Tab siwo dzi woŋlɔ nu ɖo
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">Dropdown</a>
<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>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Atikekui siwo me wotsɔa atikekuiwo ƒua gbe ɖo
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">Dropdown</a>
<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>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Sass ƒe nyawo
Nusiwo trɔna
$nav-link-padding-y: .5rem;
$nav-link-padding-x: 1rem;
$nav-link-font-size: null;
$nav-link-font-weight: null;
$nav-link-color: $link-color;
$nav-link-hover-color: $link-hover-color;
$nav-link-transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out;
$nav-link-disabled-color: $gray-600;
$nav-tabs-border-color: $gray-300;
$nav-tabs-border-width: $border-width;
$nav-tabs-border-radius: $border-radius;
$nav-tabs-link-hover-border-color: $gray-200 $gray-200 $nav-tabs-border-color;
$nav-tabs-link-active-color: $gray-700;
$nav-tabs-link-active-bg: $body-bg;
$nav-tabs-link-active-border-color: $gray-300 $gray-300 $nav-tabs-link-active-bg;
$nav-pills-border-radius: $border-radius;
$nav-pills-link-active-color: $component-active-color;
$nav-pills-link-active-bg: $component-active-bg;
JavaScript ƒe nuwɔna
Zã tab JavaScript plugin—de eme ɖekaɖeka alo to bootstrap.js
faɛl si woƒo ƒu la dzi—be nàkeke míaƒe mɔfiamewo ƒe tabwo kple atikekuiwo ɖe enu be nàwɔ teƒea me nyatakakawo ƒe akpa siwo woate ŋu aƒo tagba ɖo.
Dynamic tabbed interfaces, abe alesi woɖe eme le WAI ARIA Authoring Practices me ene la, bia role="tablist"
, role="tab"
, role="tabpanel"
, kple aria-
nɔnɔme bubuwo be woatsɔ agblɔ woƒe wɔwɔme, dɔwɔwɔ kple nɔnɔme si li fifia na kpekpeɖeŋu mɔ̃ɖaŋunuwo (abe screen readers ene) zãlawo. Abe nuwɔna nyuitɔ ene la, míeɖo aɖaŋu be nàzã <button>
nusiwo le tabawo me, elabena esiawo nye dziɖuɖu siwo hea tɔtrɔ si trɔna vɛ, ke menye kadodo siwo yia axa alo teƒe yeye aɖe dzi o.
De dzesii be mele be dynamic tabbed interfaces nakpɔ dropdown menus o, elabena esia hea zazã kple mɔɖeɖe siaa ƒe kuxiwo vɛ . Le zazã ƒe nukpɔsusu nu la, nyateƒe si wònye be tab si woɖe fia fifia ƒe trigger element medzena enumake o (abe alesi wòle le dropdown menu si wotu la me ene) ateŋu ahe tɔtɔ vɛ. Le mɔnukpɔkpɔ ƒe nukpɔsusu nu la, mɔ si me susu le aɖeke meli fifia si dzi woato awɔ xɔtuɖoɖo sia ƒomevi ƒe nɔnɔmetata ɖe WAI ARIA ƒe ɖoɖo si sɔ nu o, si fia be womate ŋu ana kpekpeɖeŋu mɔ̃ɖaŋunuwo zazãlawo nase egɔme bɔbɔe o.
Esia nye teƒe aɖewo ƒe nyawo Home tab ƒe nya siwo do ƒome kplii. Ne èzi tab bubu dzi la, atrɔ asi le esiawo ƒe dzedzeme ŋu na esi kplɔe ɖo. JavaScript ƒe tab la trɔa klasswo be wòakpɔ emenyawo ƒe dzedzeme kple woƒe atsyã dzi. Àte ŋu azãe kple tabwo, atikekuiwo, kple .nav
mɔfianu bubu ɖesiaɖe si ŋu -ŋusẽ le.
Esia nye teƒe aɖewo ƒe nyatakaka siwo le Profile tab ƒe nya siwo do ƒome kplii. Ne èzi tab bubu dzi la, atrɔ asi le esiawo ƒe dzedzeme ŋu na esi kplɔe ɖo. JavaScript ƒe tab la trɔa klasswo be wòakpɔ emenyawo ƒe dzedzeme kple woƒe atsyã dzi. Àte ŋu azãe kple tabwo, atikekuiwo, kple .nav
mɔfianu bubu ɖesiaɖe si ŋu -ŋusẽ le.
Esia nye teƒe aɖewo ƒe nyatakaka siwo le Contact tab ƒe nya siwo do ƒome kplii. Ne èzi tab bubu dzi la, atrɔ asi le esiawo ƒe dzedzeme ŋu na esi kplɔe ɖo. JavaScript ƒe tab la trɔa klasswo be wòakpɔ emenyawo ƒe dzedzeme kple woƒe atsyã dzi. Àte ŋu azãe kple tabwo, atikekuiwo, kple .nav
mɔfianu bubu ɖesiaɖe si ŋu -ŋusẽ le.
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#contact" type="button" role="tab" aria-controls="contact" aria-selected="false">Contact</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">...</div>
</div>
Be wòakpe ɖe ŋuwò wòasɔ ɖe wò hiahiãwo nu la, esia wɔa dɔ kple dzesi si wotu ɖe <ul>
-dzi, abe alesi woɖee fia le etame ene, alo kple dzesi ɖesiaɖe si nèdi be yeaƒo “ƒo wò ŋutɔ wò” nu. De dzesii be ne èle , zãm <nav>
la, mele be nàtsɔe akpe ɖe eŋu role="tablist"
tẽ o, elabena esia agblẽ nu le element la ƒe akpa si wòwɔna ŋutɔŋutɔ abe mɔzɔzɔ ƒe dzesi ene ŋu. Ke boŋ trɔ ɖe nu bubu aɖe ŋu (le kpɔɖeŋu si le ete me la, bɔbɔe aɖe <div>
) eye nàxatsa ɖe <nav>
eŋu.
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<button class="nav-link active" id="nav-home-tab" data-bs-toggle="tab" data-bs-target="#nav-home" type="button" role="tab" aria-controls="nav-home" aria-selected="true">Home</button>
<button class="nav-link" id="nav-profile-tab" data-bs-toggle="tab" data-bs-target="#nav-profile" type="button" role="tab" aria-controls="nav-profile" aria-selected="false">Profile</button>
<button class="nav-link" id="nav-contact-tab" data-bs-toggle="tab" data-bs-target="#nav-contact" type="button" role="tab" aria-controls="nav-contact" aria-selected="false">Contact</button>
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">...</div>
<div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">...</div>
<div class="tab-pane fade" id="nav-contact" role="tabpanel" aria-labelledby="nav-contact-tab">...</div>
</div>
Tabs plugin la hã wɔa dɔ kple atikekuiwo.
Esia nye teƒe aɖewo ƒe nyawo Home tab ƒe nya siwo do ƒome kplii. Ne èzi tab bubu dzi la, atrɔ asi le esiawo ƒe dzedzeme ŋu na esi kplɔe ɖo. JavaScript ƒe tab la trɔa klasswo be wòakpɔ emenyawo ƒe dzedzeme kple woƒe atsyã dzi. Àte ŋu azãe kple tabwo, atikekuiwo, kple .nav
mɔfianu bubu ɖesiaɖe si ŋu -ŋusẽ le.
Esia nye teƒe aɖewo ƒe nyatakaka siwo le Profile tab ƒe nya siwo do ƒome kplii. Ne èzi tab bubu dzi la, atrɔ asi le esiawo ƒe dzedzeme ŋu na esi kplɔe ɖo. JavaScript ƒe tab la trɔa klasswo be wòakpɔ emenyawo ƒe dzedzeme kple woƒe atsyã dzi. Àte ŋu azãe kple tabwo, atikekuiwo, kple .nav
mɔfianu bubu ɖesiaɖe si ŋu -ŋusẽ le.
Esia nye teƒe aɖewo ƒe nyatakaka siwo le Contact tab ƒe nya siwo do ƒome kplii. Ne èzi tab bubu dzi la, atrɔ asi le esiawo ƒe dzedzeme ŋu na esi kplɔe ɖo. JavaScript ƒe tab la trɔa klasswo be wòakpɔ emenyawo ƒe dzedzeme kple woƒe atsyã dzi. Àte ŋu azãe kple tabwo, atikekuiwo, kple .nav
mɔfianu bubu ɖesiaɖe si ŋu -ŋusẽ le.
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="pills-home-tab" data-bs-toggle="pill" data-bs-target="#pills-home" type="button" role="tab" aria-controls="pills-home" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-profile-tab" data-bs-toggle="pill" data-bs-target="#pills-profile" type="button" role="tab" aria-controls="pills-profile" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-contact-tab" data-bs-toggle="pill" data-bs-target="#pills-contact" type="button" role="tab" aria-controls="pills-contact" aria-selected="false">Contact</button>
</li>
</ul>
<div class="tab-content" id="pills-tabContent">
<div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab">...</div>
<div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">...</div>
<div class="tab-pane fade" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab">...</div>
</div>
Eye kple atikekui siwo le tsitrenu.
Esia nye teƒe aɖewo ƒe nyawo Home tab ƒe nya siwo do ƒome kplii. Ne èzi tab bubu dzi la, atrɔ asi le esiawo ƒe dzedzeme ŋu na esi kplɔe ɖo. JavaScript ƒe tab la trɔa klasswo be wòakpɔ emenyawo ƒe dzedzeme kple woƒe atsyã dzi. Àte ŋu azãe kple tabwo, atikekuiwo, kple .nav
mɔfianu bubu ɖesiaɖe si ŋu -ŋusẽ le.
Esia nye teƒe aɖewo ƒe nyatakaka siwo le Profile tab ƒe nya siwo do ƒome kplii. Ne èzi tab bubu dzi la, atrɔ asi le esiawo ƒe dzedzeme ŋu na esi kplɔe ɖo. JavaScript ƒe tab la trɔa klasswo be wòakpɔ emenyawo ƒe dzedzeme kple woƒe atsyã dzi. Àte ŋu azãe kple tabwo, atikekuiwo, kple .nav
mɔfianu bubu ɖesiaɖe si ŋu -ŋusẽ le.
Esia nye teƒe aɖewo ƒe nyatakaka siwo le Messages tab ƒe nya siwo do ƒome kplii me. Ne èzi tab bubu dzi la, atrɔ asi le esiawo ƒe dzedzeme ŋu na esi kplɔe ɖo. JavaScript ƒe tab la trɔa klasswo be wòakpɔ emenyawo ƒe dzedzeme kple woƒe atsyã dzi. Àte ŋu azãe kple tabwo, atikekuiwo, kple .nav
mɔfianu bubu ɖesiaɖe si ŋu -ŋusẽ le.
Esia nye teƒe aɖewo ƒe nyatakaka siwo le Settings tab ƒe nya siwo do ƒome kplii me. Ne èzi tab bubu dzi la, atrɔ asi le esiawo ƒe dzedzeme ŋu na esi kplɔe ɖo. JavaScript ƒe tab la trɔa klasswo be wòakpɔ emenyawo ƒe dzedzeme kple woƒe atsyã dzi. Àte ŋu azãe kple tabwo, atikekuiwo, kple .nav
mɔfianu bubu ɖesiaɖe si ŋu -ŋusẽ le.
<div class="d-flex align-items-start">
<div class="nav flex-column nav-pills me-3" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<button class="nav-link active" id="v-pills-home-tab" data-bs-toggle="pill" data-bs-target="#v-pills-home" type="button" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</button>
<button class="nav-link" id="v-pills-profile-tab" data-bs-toggle="pill" data-bs-target="#v-pills-profile" type="button" role="tab" aria-controls="v-pills-profile" aria-selected="false">Profile</button>
<button class="nav-link" id="v-pills-messages-tab" data-bs-toggle="pill" data-bs-target="#v-pills-messages" type="button" role="tab" aria-controls="v-pills-messages" aria-selected="false">Messages</button>
<button class="nav-link" id="v-pills-settings-tab" data-bs-toggle="pill" data-bs-target="#v-pills-settings" type="button" role="tab" aria-controls="v-pills-settings" aria-selected="false">Settings</button>
</div>
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab">...</div>
<div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab">...</div>
<div class="tab-pane fade" id="v-pills-messages" role="tabpanel" aria-labelledby="v-pills-messages-tab">...</div>
<div class="tab-pane fade" id="v-pills-settings" role="tabpanel" aria-labelledby="v-pills-settings-tab">...</div>
</div>
</div>
Nyatakaka ƒe nɔnɔmewo zazã
Àte ŋu awɔ tab alo pill navigation ŋudɔ JavaScript aɖeke maŋlɔ to element aɖe gbɔgblɔ data-bs-toggle="tab"
alo ɖe edzi ko me. data-bs-toggle="pill"
Zã nyatakaka ƒe nɔnɔme siawo le .nav-tabs
alo .nav-pills
.
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="messages-tab" data-bs-toggle="tab" data-bs-target="#messages" type="button" role="tab" aria-controls="messages" aria-selected="false">Messages</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings" type="button" role="tab" aria-controls="settings" aria-selected="false">Settings</button>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
<div class="tab-pane" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane" id="messages" role="tabpanel" aria-labelledby="messages-tab">...</div>
<div class="tab-pane" id="settings" role="tabpanel" aria-labelledby="settings-tab">...</div>
</div>
To JavaScript dzi
Na tabbable tabs nawɔ dɔ to JavaScript dzi (ele be woawɔ tab ɖesiaɖe ŋudɔ ɖekaɖeka):
var triggerTabList = [].slice.call(document.querySelectorAll('#myTab button'))
triggerTabList.forEach(function (triggerEl) {
var tabTrigger = new bootstrap.Tab(triggerEl)
triggerEl.addEventListener('click', function (event) {
event.preventDefault()
tabTrigger.show()
})
})
Àte ŋu awɔ tab ɖekaɖekawo ŋudɔ le mɔ vovovowo nu:
var triggerEl = document.querySelector('#myTab button[data-bs-target="#profile"]')
bootstrap.Tab.getInstance(triggerEl).show() // Select tab by name
var triggerFirstTabEl = document.querySelector('#myTab li:first-child button')
bootstrap.Tab.getInstance(triggerFirstTabEl).show() // Select first tab
Fade ƒe ŋusẽkpɔɖeamedzi
Be nàna tabwo naɖiɖi la, tsɔe kpe .fade
ɖe wo dometɔ ɖesiaɖe .tab-pane
ŋu . Ele be tab ƒe akpa gbãtɔ hã .show
nana nya siwo le gɔmedzedzea me la nadze.
<div class="tab-content">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane fade" id="messages" role="tabpanel" aria-labelledby="messages-tab">...</div>
<div class="tab-pane fade" id="settings" role="tabpanel" aria-labelledby="settings-tab">...</div>
</div>
Mɔnuwo
Mɔnu siwo mewɔ ɖeka kple ɣeyiɣi aɖeke o kple tɔtrɔwo
API mɔnuwo katã nye asynchronous eye wodzea tɔtrɔ gɔme . Wotrɔna yia ame si le ka ƒom na la gbɔ ne wonya dze tɔtrɔa gɔme ko gake hafi wòwu enu . Tsɔ kpe ɖe eŋu la, woaŋe aɖaba aƒu mɔnu ƒe yɔyɔ aɖe dzi le akpa si le tɔtrɔm dzi .
constructor
Ewɔa tab element kple emenyawo ƒe nugoe ŋudɔ. Ele be tab nanye data-bs-target
alo, ne èle kadodo aɖe zãm la, href
nɔnɔme aɖe, si aɖo taɖodzinu na nugoe ƒe node le DOM me.
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="messages-tab" data-bs-toggle="tab" data-bs-target="#messages" type="button" role="tab" aria-controls="messages" aria-selected="false">Messages</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings" type="button" role="tab" aria-controls="settings" aria-selected="false">Settings</button>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
<div class="tab-pane" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane" id="messages" role="tabpanel" aria-labelledby="messages-tab">...</div>
<div class="tab-pane" id="settings" role="tabpanel" aria-labelledby="settings-tab">...</div>
</div>
<script>
var firstTabEl = document.querySelector('#myTab li:last-child button')
var firstTab = new bootstrap.Tab(firstTabEl)
firstTab.show()
</script>
ɖe fia
Tia tab si wona eye wòaɖe eƒe akpa si do ƒome kplii afia. Tab bubu ɖesiaɖe si wotia va yi la va zua esi wometia o eye eƒe akpa si do ƒome kplii la ɣlana. Trɔ yi yɔla gbɔ hafi woɖe tab ƒe akpaa fia ŋutɔŋutɔ (si nye hafi shown.bs.tab
nudzɔdzɔa nadzɔ).
var someTabTriggerEl = document.querySelector('#someTabTrigger')
var tab = new bootstrap.Tab(someTabTriggerEl)
tab.show()
tsɔe ƒu gbe
Egblẽa nu le element aɖe ƒe tab ŋu.
getInstance ƒe kpɔɖeŋu
Static mɔnu si ɖea mɔ na wò be nàxɔ tab ƒe kpɔɖeŋu si do ƒome kple DOM element aɖe
var triggerEl = document.querySelector('#trigger')
var tab = bootstrap.Tab.getInstance(triggerEl) // Returns a Bootstrap tab instance
xɔAloWɔwɔKpɔɖeŋu
Static mɔnu si ɖea mɔ na wò be nàxɔ tab ƒe kpɔɖeŋu si do ƒome kple DOM element aɖe, alo awɔ yeye nenye be womedze egɔme o
var triggerEl = document.querySelector('#trigger')
var tab = bootstrap.Tab.getOrCreateInstance(triggerEl) // Returns a Bootstrap tab instance
Nudzɔdzɔwo
Ne èle tab yeye aɖe ɖem fia la, nudzɔdzɔawo dzona le ɖoɖo si gbɔna nu:
hide.bs.tab
(le tab si le dɔ wɔm fifia dzi)show.bs.tab
(le tab si woaɖe afia la dzi)hidden.bs.tab
(le tab si le dɔ wɔm va yi dzi la, esi lehide.bs.tab
nudzɔdzɔa gome la ke)shown.bs.tab
(le tab si woɖe fia teti koe nye ema si le dɔ wɔm yeyee la dzi la, esi sɔ kple esi wowɔ nashow.bs.tab
wɔnaa tɔ)
Ne tab aɖeke menɔ dɔ wɔm xoxo o la, ekema womaɖe asi le hide.bs.tab
kple nudzɔdzɔawo ŋu o.hidden.bs.tab
Nudzɔdzɔ ƒomevi | Nuɖᴐɖᴐ |
---|---|
show.bs.tab |
Nudzɔdzɔ sia dzona le tab show dzi, gake hafi woaɖe tab yeyea afia. Zã event.target kple event.relatedTarget nàtsɔ aɖo taɖodzinu na tab si le dɔ wɔm kple tab si le dɔ wɔm va yi (ne ele eme) ɖe wo nɔewo yome. |
shown.bs.tab |
Nudzɔdzɔ sia dzona le tab ɖeɖefia me ne woɖe tab aɖe fia vɔ. Zã event.target kple event.relatedTarget nàtsɔ aɖo taɖodzinu na tab si le dɔ wɔm kple tab si le dɔ wɔm va yi (ne ele eme) ɖe wo nɔewo yome. |
hide.bs.tab |
Nudzɔdzɔ sia doa dzo ne woaɖe tab yeye aɖe afia (eye to esia me la, woaɣla tab si le dɔ wɔm va yi). Zã event.target kple event.relatedTarget nàtsɔ aɖo taɖodzinu na tab si le dɔ wɔm fifia kple tab yeye si awɔ dɔ kpuie la, ɖe wo nɔewo yome. |
hidden.bs.tab |
Nudzɔdzɔ sia dzona ne woɖe tab yeye aɖe fia vɔ (eye to esia me la, woɣla tab si le dɔ wɔm va yi). Zã event.target kple event.relatedTarget nàtsɔ aɖo taɖodzinu na tab si le dɔ wɔm va yi kple tab yeye si le dɔ wɔm la, ɖe wo nɔewo yome. |
var tabEl = document.querySelector('button[data-bs-toggle="tab"]')
tabEl.addEventListener('shown.bs.tab', function (event) {
event.target // newly activated tab
event.relatedTarget // previous active tab
})