Navs
Nwoma ne nhwɛsoɔ a ɛfa sɛdeɛ wɔde Bootstrap no akwantuo afã a ɛka ho no bedi dwuma.
Navigation a ɛwɔ Bootstrap mu no kyɛ general markup ne styles, efi base .nav
class no so kosi active ne disabled states so. Sesa modifier classes na dannan style biara ntam.
Wɔde flexbox na ɛkyekyee base .nav
component no na ɛma fapem a ɛyɛ den a wɔde besi navigation components ahorow nyinaa. Ɛka style overrides binom (a wɔde yɛ adwuma wɔ lists ho), link padding bi ma hit areas akɛse, ne basic disabled styling.
Base .nav
component no nka .active
tebea biara ho. Nhwɛso ahorow a edidi so yi de adesuakuw no ka ho, titiriw de kyerɛ sɛ adesuakuw pɔtee yi nkanyan ɔkwan titiriw biara a wɔfa so yɛ no.
Wɔde adesua ahorow di dwuma wɔ ne nyinaa mu, enti wo markup betumi ayɛ super flexible. Fa s te sɛ atifi hɔ no di dwuma, anaa fa ka element <ul>
bi bobɔ wo de . <nav>
Efisɛ .nav
uses display: flex
, nav links no yɛ wɔn ade sɛnea nav nneɛma bɛyɛ no, nanso enni markup foforo no.
Sesa .nav
s component no kwan so de modifiers ne utilities. Fa fra mu sɛnea ɛho hia, anaasɛ si w’ankasa de.
Sesa wo nav no horizontal alignment no ne flexbox utilities . Sɛnea wɔahyɛ no, navs no yɛ benkum so, nanso ɛnyɛ den sɛ wobɛsesa no akɔ mfinimfini anaa nifa so.
Mfinimfini ne .justify-content-center
: .
Nifa-a ɛne .justify-content-end
: .
Stack wo navigation denam nsakrae a wobɛsesa flex ade no kwankyerɛ ne .flex-column
utility no so. Ɛho hia sɛ wo stack wɔn wɔ viewports binom so nanso ɛnyɛ afoforo so? Fa nkyerɛase ahorow a ɛyɛ mmuae no di dwuma (sɛ nhwɛso no, .flex-sm-column
).
Sɛnea ɛte daa no, vertical navigation betumi ayɛ yiye a <ul>
s nka ho, nso.
Fa nav titiriw no fi soro na ɛde .nav-tabs
adesuakuw no ka ho ma ɛyɛ tabbed interface. Fa wɔn yɛ tabbable regions denam yɛn tab JavaScript plugin no so .
Fa saa HTML koro no ara, nanso fa di dwuma .nav-pills
mmom:
Hyɛ wo .nav
's mu nsɛm no ma ɛntrɛw ntrɛwmu a ɛwɔ hɔ nyinaa mu biako a ɛwɔ modifier class abien no mu. Sɛ wopɛ sɛ wode wo .nav-item
s hyɛ baabi a ɛwɔ hɔ nyinaa ma sɛnea ɛfata a, fa .nav-fill
. Hyɛ no nsow sɛ wɔafa horizontal space nyinaa, nanso ɛnyɛ nav ade biara na ne tɛtrɛtɛ yɛ pɛ.
Sɛ wode <nav>
-based navigation redi dwuma a, hwɛ hu sɛ wode bɛka .nav-item
anchors no ho.
Sɛ wopɛ nneɛma a ne tɛtrɛtɛ yɛ pɛ a, fa .nav-justified
. Nav links bɛfa horizontal space nyinaa, nanso ɛnte sɛ .nav-fill
atifi hɔ no, nav adeɛ biara bɛyɛ ne tɛtrɛtɛ korɔ.
Te sɛ .nav-fill
nhwɛso a wɔde <nav>
-gyina akwantuo so di dwuma no, hwɛ hu sɛ wode bɛka .nav-item
ankora no ho.
Sɛ wuhia nav nsakrae a ɛyɛ mmuae a, susuw ho sɛ wode flexbox utilities ahorow a ɛtoatoa so bedi dwuma . Bere a ɛyɛ verbose kɛse no, saa utilities yi ma customization kɛse wɔ mmuae breakpoints nyinaa mu. Wɔ nhwɛsoɔ a ɛwɔ aseɛ ha yi mu no, yɛn nav no bɛboaboa ano wɔ breakpoint a ɛba fam koraa no so, afei wɔbɛdane akɔ horizontal layout a ɛhyɛ width a ɛwɔ hɔ no ma a ɛfiri aseɛ firi breakpoint ketewa no so.
Sɛ wode navs redi dwuma de ama navigation bar a, hwɛ hu sɛ wode a bɛka role="navigation"
ɔwofo container a ntease wom sen biara a ɛwɔ <ul>
, anaasɛ fa <nav>
element bi kyekyere navigation no nyinaa ho. Mfa dwuma no nka <ul>
n’ankasa ho, efisɛ eyi remma mfiridwuma a ɛboa no rentumi mfa ho dawuru sɛ ɛyɛ din ankasa.
Hyɛ no nsow sɛ ɛnsɛ sɛ wɔde navigation bars, mpo sɛ wɔayɛ no aniwa so sɛ tabs ne .nav-tabs
class no a, ɛnsɛ sɛ wɔde role="tablist"
, role="tab"
anaasɛ role="tabpanel"
attributes ma. Eyinom fata ma tabbed interfaces a ɛyɛ nnam nkutoo, sɛnea wɔaka ho asɛm wɔ WAI ARIA Authoring Practices . Hwɛ JavaScript suban ma dynamic tabbed interfaces wɔ ɔfa yi mu ma nhwɛso.
Fa menu ahorow a ɛwɔ fam no ka ho a HTML kakra aka ho ne JavaScript plugin a ɛwɔ fam no .
Fa tab JavaScript plugin no di dwuma—fa ka ho mmiako mmiako anaa fa bootstrap.js
fael a wɔaboaboa ano no so—na trɛw yɛn navigational tabs ne pills no mu ma yɛ tabable panes a ɛwɔ mpɔtam hɔ nsɛm, mpo denam dropdown menus so.
Sɛ worekyekye yɛn JavaScript no afi fibea a, ɛhwehwɛ sɛutil.js
.
Dynamic tabbed interfaces, sɛnea wɔaka ho asɛm wɔ WAI ARIA Authoring Practices , hwehwɛ role="tablist"
, role="tab"
, role="tabpanel"
, ne aria-
su afoforo sɛnea ɛbɛyɛ a wɔde wɔn nhyehyɛe, dwumadie ne mprempren tebea bɛma wɔn a wɔde mfiridwuma a ɛboa (te sɛ screen readers) di dwuma no.
Hyɛ no nsow sɛ ɛnsɛ sɛ dynamic tabbed interfaces no kura dropdown menus, efisɛ eyi de nsɛm a ɛfa dwumadie ne kwan a wɔfa so kɔ hɔ nyinaa ba. Sɛ yɛhwɛ sɛnea wobetumi de adi dwuma a, nokwasɛm a ɛyɛ sɛ tab a wɔada no adi mprempren no trigger element no ntumi nhu ntɛm ara (sɛnea ɛwɔ dropdown menu a wɔato mu no mu) no betumi ama adwene atu afra. Sɛ yɛhwɛ kwan a wɔfa so kɔ hɔ a, mprempren ɔkwan biara nni hɔ a ntease wom a wɔbɛfa so ayɛ saa ɔdansi yi ho mfonini akɔ WAI ARIA nhyehyɛe a ɛwɔ hɔ no so, a ɛkyerɛ sɛ ɛnyɛ mmerɛw sɛ wɔbɛma wɔn a wɔde mfiridwuma a ɛboa di dwuma no ate ase.
Raw denim ebia wontee wɔn ho asɛm jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth owura ahotew. Mustache cliche bere tiaa mu, williamsburg carles vegan helvetica. Reprehenderit namkumfoɔ retro keffiyeh daeɛ kyerefoɔ synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Ɔde ne nsa kyerɛɛ ne so, na ɔde ne nsa kyerɛɛ ne so bio. Aliquip placeat salvia a ɔyɛ ɔbarima a ɔpɛ sɛ ɔyɛ biribi. Seitan aliquip quis cardigan american ntade, namtɔnfo voluptate nisi qui.
Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.
Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.
Sɛnea ɛbɛyɛ a ɛbɛboa ma ɛne w’ahiade ahyia no, eyi de <ul>
-based markup yɛ adwuma, sɛnea wɔakyerɛ wɔ atifi hɔ no, anaasɛ “roll your own” markup biara a wopɛ. Hyɛ no nsow sɛ sɛ wode redi dwuma <nav>
a, ɛnsɛ sɛ wode ka ho role="tablist"
tẽẽ, efisɛ eyi bɛbu element no kurom dwumadi sɛ akwantu agyiraehyɛde no so. Mmom no, dan kɔ element foforo bi so (wɔ nhwɛso a ɛwɔ ase ha no mu no, a simple <div>
) na fa kyekyere <nav>
ho.
Tabs plugin no nso ne pills yɛ adwuma.
Nea efi mu ba no yɛ occaecat ullamco amet non eiusmod nostrud dolore irure incididunt est duis anim sunt officia. Fugiat velit proident aliquip nisi incididunt hwene mu apɔw-mu-teɛteɛ proident est nisi. Irure magna elit commodo anim ex veniam culpa eiusmod id nostrud tena cupidat wɔ veniam ad. Eiusmod consequat eu adipisicing a ɛyɛ ketewaa bi a ɛyɛ anim a ɛyɛ cupidatat culpa excepteur quis. Occaecat tra eu apɔw-mu-teɛteɛ irure Lorem incididunt nostrud.
Ad pariatur nostrud pariatur exercitation ipsum ipsum culpa mollit commodo mollit ex. Aute sunt incididunt amet commodo est sint nisi deserunt pariatur do. Aliquip ex eiusmod voluptate exercitation cillum id incididunt elit sunt. Qui minim sit magna Lorem id et dolore velit Lorem amet exercitation duis deserunt. Anim id labore elit adipisicing ut in id occaecat pariatur ut ullamco ea tempor duis.
Est quis nulla laborum officia ad nisi ex nostrud culpa Lorem excepteur aliquip dolor aliqua irure ex. Nulla ut duis ipsum nisi elit fugiat commodo sunt reprehenderit laborum veniam eu veniam. Eiusmod minim exercitation fugiat irure ex labore incididunt do fugiat commodo aliquip sit id deserunt reprehenderit aliquip nostrud. Amet ex cupidatat excepteur aute veniam incididunt mollit cupidatat esse irure officia elit do ipsum ullamco Lorem. Ullamco ut ad minim do mollit labore ipsum laboris ipsum commodo sunt tempor enim incididunt. Commodo quis sunt dolore aliquip aute tempor irure magna enim minim reprehenderit. Ullamco consectetur culpa veniam sint cillum aliqua incididunt velit ullamco sunt ullamco quis quis commodo voluptate. Mollit nulla nostrud adipisicing aliqua cupidatat aliqua pariatur mollit voluptate voluptate consequat non.
Na ɛne nnuru a wɔde di dwuma gyina hɔ.
Cillum ad ut irure bere tiaa mu velit nostrud occaecat ullamco aliqua anim Lorem sint. Veniam sint duis incididunt yɛ esse magna mollit gye sɛ ɛyɛ adwumaden qui. Id id reprehenderit tena ase est eu aliqua occaecat quis ne velit gye sɛ adwumaden a wɔfrɛ no mollit dolore eiusmod. Ipsum dolor wɔ occaecat commodo ne voluptate a ɛyɛ ketewaa bi a ɛkyerɛ sɛ ɛyɛ mollit pariatur. Deserunt non laborum enim ne cillum eu deserunt a ɛnyɛ adwumaden a ɛnyɛ adwumaden a ɛyɛ ketewaa bi.
Culpa dolor voluptate do laboris laboris irure reprehenderit id incididunt duis pariatur mollit aute magna pariatur consectetur. Eu veniam duis non ut dolor deserunt commodo et minim in quis laboris ipsum velit id veniam. Quis ut consectetur adipisicing officia excepteur non sit. Ut et elit aliquip labore Lorem enim eu. Ullamco mollit occaecat dolore ipsum id officia mollit qui esse anim eiusmod do sint minim consectetur qui.
Fugiat id quis dolor culpa eiusmod anim velit excepteur proident dolor aute qui magna. Ad proident laboris ullamco esse anim Lorem Lorem veniam quis Lorem irure occaecat velit nostrud magna nulla. Velit et et proident Lorem do ea tempor officia dolor. Reprehenderit Lorem aliquip labore est magna commodo est ea veniam consectetur.
Eu dolore ea ullamco dolore Lorem id cupidatat excepteur reprehenderit consectetur elit id dolor proident in cupidatat officia. Voluptate excepteur commodo labore nisi cillum duis aliqua do. Aliqua amet qui mollit consectetur nulla mollit velit aliqua veniam nisi id do Lorem deserunt amet. Culpa ullamco sit adipisicing labore officia magna elit nisi in aute tempor commodo eiusmod.
Wubetumi ama tab anaa pill navigation ayɛ adwuma a worenkyerɛw JavaScript biara denam element bi a wobɛkyerɛ ara kwa data-toggle="tab"
anaasɛ wobɛka so. data-toggle="pill"
Fa saa data su ahorow yi di dwuma wɔ .nav-tabs
anaa .nav-pills
.
Ma tabable tabs no nyɛ adwuma denam JavaScript so (ɛsɛ sɛ wode tab biara yɛ adwuma mmiako mmiako):
Wubetumi ayɛ tab ankorankoro adwuma wɔ akwan horow pii so:
Sɛ wopɛ sɛ tab ahorow no bɛyera a, fa ka .fade
emu biara ho .tab-pane
. Ɛsɛ sɛ tab pane a edi kan no nso .show
ma nsɛm a edi kan no da adi.
Asynchronous akwan ne nsakrae ahorow
API akwan nyinaa yɛ asynchronous na ɛhyɛ nsakrae ase . Wɔsan kɔ nea ɔfrɛɛ no no nkyɛn bere a wɔafi nsakrae no ase ara pɛ nanso ansa na aba awiei . Bio nso, wobebu ani agu ɔkwan a wɔfa so frɛ ade bi a ɛresakra so no so .
Ɛma tab element ne nsɛm a ɛwɔ mu no yɛ adwuma. Ɛsɛ sɛ tab nya a data-target
anaasɛ href
targeting a container node wɔ DOM no mu.
Paw tab a wɔde ama no na ɛkyerɛ ne pane a ɛbata ho. Tab foforo biara a na wɔadi kan apaw no bɛyɛ nea wɔanpaw na ne pane a ɛbata ho no sie. San kɔ nea ɔfrɛ no no nkyɛn ansa na wɔakyerɛ tab pane no ankasa (kyerɛ sɛ ansa na shown.bs.tab
asɛm no asi).
Ɔsɛe element bi tab no.
Sɛ worekyerɛ tab foforo a, nsɛm a esisi no bɛtow nnidiso nnidiso a edidi so yi:
hide.bs.tab
(wɔ tab a ɛreyɛ adwuma mprempren no so)show.bs.tab
(wɔ tab a wɔrebɛkyerɛ no so)hidden.bs.tab
(wɔ active tab a atwam no so no, nea ɛwɔhide.bs.tab
adeyɛ no ho no ara)shown.bs.tab
(wɔ tab a wɔakyerɛ seesei ara a ɛyɛ adwuma foforo no so no, nea ɛwɔshow.bs.tab
adeyɛ no ho no ara)
Sɛ na tab biara nni hɔ a ɛyɛ adwuma dedaw a, ɛnde wɔrentow hide.bs.tab
ne hidden.bs.tab
nsɛm a esisi no.
Nsɛm a Ɛsisii no Su | Nkyerɛmu |
---|---|
kyerɛ.bs.tab no | Saa adeyɛ yi tow wɔ tab show so, nanso ansa na wɔakyerɛ tab foforo no. Fa event.target ne di dwuma event.relatedTarget fa w’ani si active tab ne active tab a atwam no so (sɛ ɛwɔ hɔ a) sɛnea ɛte biara. |
wɔakyerɛ.bs.tab | Saa adeyɛ yi tow wɔ tab show so bere a wɔakyerɛ tab bi akyi. Fa event.target ne di dwuma event.relatedTarget fa w’ani si active tab ne active tab a atwam no so (sɛ ɛwɔ hɔ a) sɛnea ɛte biara. |
hide.bs.tab no ho nsɛm | Saa adeyɛ yi tow bere a ɛsɛ sɛ wɔkyerɛ tab foforo (na ɛnam saa kwan yi so no ɛsɛ sɛ wɔde tab a ɛyɛ adwuma a atwam no sie). Fa event.target ne di dwuma event.relatedTarget fa w’ani si tab a ɛreyɛ adwuma mprempren ne tab foforo a ɛrenkyɛ na ɛreyɛ adwuma no so, sɛnea ɛte biara. |
ahintaw.bs.tab no | Saa adeyɛ yi tow bere a wɔakyerɛ tab foforo akyi (na ɛnam saa kwan yi so no wɔde tab a ɛyɛ adwuma a atwam no asie). Fa event.target ne di dwuma event.relatedTarget fa w’ani si tab a ɛreyɛ adwuma a atwam no ne tab a ɛreyɛ adwuma foforo no so, sɛnea ɛte biara. |