I-Navs
Amadokhumenti nezibonelo zokuthi zisetshenziswa kanjani izingxenye ze-Bootstrap zokuzulazula ezifakiwe.
Isisekelo nav
Ukuzulazula kutholakala ku-Bootstrap yabelana ngemakhaphu evamile nezitayela, kusukela kusigaba sesisekelo .nav
kuya ezifundazweni ezisebenzayo nezikhubazekile. Shintshanisa amakilasi okushintsha ukuze ushintshe phakathi kwesitayela ngasinye.
Ingxenye yesisekelo .nav
yakhiwe nge-flexbox futhi inikeza isisekelo esiqinile sokwakha zonke izinhlobo zezingxenye zokuzulazula. Kubandakanya ukubhala ngaphezulu kwesitayela esithile (sokusebenza ngezinhlu), ezinye izixhumanisi zokunamathisela izindawo ezinkulu ezishaywayo, kanye nesitayela esiyisisekelo esikhubazekile.
Ingxenye yesisekelo .nav
ayifaki noma yisiphi .active
isimo. Izibonelo ezilandelayo zifaka ikilasi, ikakhulukazi ukukhombisa ukuthi lesi sigaba asibangeli isitayela esikhethekile.
Amakilasi asetshenziswa kulo lonke, ngakho umaki wakho ungaguquguquka kakhulu. Sebenzisa u <ul>
-s njengangenhla, <ol>
uma ukuhleleka kwezinto zakho kubalulekile, noma gingqa eyakho ngento <nav>
. Ngoba .nav
ukusetshenziswa display: flex
, izixhumanisi ze-nav ziziphatha ngendlela efanayo nezinto ze-nav, kodwa ngaphandle kwemakhaphu eyengeziwe.
Izitayela ezitholakalayo
Shintsha isitayela sengxenye ye- .nav
s ngezilungisi kanye nezinsiza. Hlanganisa futhi ufanise njengoba kudingeka, noma wakhe owakho.
Ukuqondanisa okuvundlile
Shintsha ukuqondanisa okuvundlile kwe-nav yakho nezinsiza ze- flexbox . Ngokuzenzakalelayo, ama-navs aqondaniswe kwesokunxele, kodwa ungakwazi ukuwashintsha kalula ukuze aqondaniswe maphakathi noma kwesokudla.
Kuphakathi kokuthi .justify-content-center
:
Iqondaniswe kwesokudla ne- .justify-content-end
:
Iqondile
Beka ukuzulazula kwakho ngokushintsha isiqondiso sento eguquguqukayo ngohlelo .flex-column
lokusebenza. Udinga ukuwabeka kwezinye izindawo zokubuka kodwa hhayi kwezinye? Sebenzisa izinguqulo eziphendulayo (isb, .flex-sm-column
).
Njengenjwayelo, ukuzulazula okuqondile kungenzeka ngaphandle <ul>
kuka-s, futhi.
Amathebhu
Ithatha i-nav eyisisekelo kusuka phezulu futhi yengeza .nav-tabs
iklasi ukuze ikhiqize isixhumi esibonakalayo esinamathebhu. Zisebenzise ukuze udale izifunda ezithintekayo ngethebhu yethu i- JavaScript plugin .
Amaphilisi
Thatha leyo HTML efanayo, kodwa sebenzisa .nav-pills
esikhundleni salokho:
Gcwalisa futhi ubeke izizathu
Phoqa .nav
okuqukethwe kwakho ukunweba ububanzi obugcwele obutholakalayo izigaba ezimbili zesilungisi. Ukuze ugcwalise ngokulinganayo zonke izikhala ezitholakalayo nge- .nav-item
s yakho, sebenzisa .nav-fill
. Qaphela ukuthi sonke isikhala esivundlile sigcwele, kodwa akuzona zonke izinto ze-nav ezinobubanzi obufanayo.
Uma usebenzisa <nav>
ukuzulazula okusekelwe, qiniseka ukuthi ufaka phakathi .nav-item
kwamahange.
Ukuze uthole ama-elementi anobubanzi obulinganayo, sebenzisa .nav-justified
. Sonke isikhala esivundlile sizosetshenziswa izixhumanisi ze-nav, kodwa ngokungafani nalokhu .nav-fill
okungenhla, yonke into ye-nav izoba nobubanzi obufanayo.
Ngokufanayo .nav-fill
nesibonelo sokusebenzisa <nav>
ukuzulazula okusekelwe, qiniseka ukuthi ufaka phakathi .nav-item
kwamahange.
Ukusebenza ngezinsiza eziguqukayo
Uma udinga ukuhlukahluka okusabelayo kwe-nav, cabanga ukusebenzisa uchungechunge lwezinsiza ze- flexbox . Ngenkathi i-verbose kakhudlwana, lezi zinsiza zinikeza ukwenza ngokwezifiso okukhulu kuwo wonke ama-breakpoints asabelayo. Esibonelweni esingezansi, i-nav yethu izopakishwa endaweni yokuphumula ephansi kakhulu, bese ijwayelana nesakhiwo esivundlile esigcwalisa ububanzi obutholakalayo kusukela endaweni encane yokuhlukana.
Mayelana nokufinyeleleka
Uma usebenzisa i-navs ukuze unikeze ibha yokuzulazula, qiniseka ukuthi ungeza u-a role="navigation"
esiqukathi esinengqondo kunazo zonke esingumzali se- <ul>
, noma usonge into ethile kukho <nav>
konke ukuzulazula. Ungangezi indima <ul>
kuyona uqobo, njengoba lokhu kuzoyivimbela ukuthi imenyezelwe njengohlu lwangempela ngobuchwepheshe obusizayo.
Qaphela ukuthi amabha okuzulazula, ngisho noma enziwe isitayela njengamathebhu anesigaba .nav-tabs
, akufanele anikezwe , role="tablist"
noma role="tab"
izibaluli role="tabpanel"
. Lokhu kulungele kuphela ukuxhumana kwamathebhu ashukumisayo, njengoba kuchazwe ku- WAI ARIA Imikhuba Yokugunyaza . Bona impatho ye-JavaScript yezindawo zokusebenzelana zamathebhu ashukumisayo kulesi sigaba njengesibonelo.
Ukusebenzisa okwehliswayo
Engeza amamenyu okwehlayo nge-HTML encane eyengeziwe kanye ne- plugin ye-JavaScript eyehlayo .
Amathebhu anokwehliswayo
Amaphilisi ane dropdowns
Ukuziphatha kweJavaScript
Sebenzisa i-plugin yethebhu ye-JavaScript—ifake ngayodwa noma ngefayela elihlanganisiwe bootstrap.js
—ukuze unwebe amathebhu ethu okuzulazula namaphilisi ukuze udale amafasitelana aphathekayo wokuqukethwe kwasendaweni, ngisho nangamamenyu okwehlayo.
Uma wakha i-JavaScript yethu ngomthombo, idingautil.js
.
Izixhumi ezibonakalayo ezinamathebhu anamandla, njengoba kuchazwe ku- WAI ARIA Imikhuba Yokugunyaza , idinga role="tablist"
, role="tab"
, role="tabpanel"
, nezibaluli ezengeziwe aria-
ukuze kudluliselwe ukwakheka kwazo, ukusebenza nesimo samanje kubasebenzisi bobuchwepheshe obusizayo (njengabafundi besikrini).
Qaphela ukuthi ukuxhumana kwamathebhu ashukumisayo akufanele kuqukathe amamenyu okwehlayo, njengoba lokhu kubangela kokubili izinkinga zokusebenziseka nokufinyeleleka. Ngokombono wokusebenziseka, iqiniso lokuthi i-elementi ye-trigger yethebhu ebonisiwe okwamanje ayibonakali ngokushesha (njengoba ingaphakathi kwemenyu yokudonsela phansi evaliwe) ingabangela ukudideka. Ngokombono wokufinyeleleka, okwamanje ayikho indlela ephusile yokubeka lolu hlobo lokwakha kuphethini evamile ye-WAI ARIA, okusho ukuthi ngeke yenziwe iqondakale kalula kubasebenzisi bobuchwepheshe obusizayo.
I-denim eluhlaza cishe awuzange uzwe ngabo izikhindi ze-jean Austin. I-Nesciunt tofu stumptown aliqua, i-retro synth master cleanse. Amadevu cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Ijezi le-Cosby eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher 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.
Ukusiza ukulingana nezidingo zakho, lokhu kusebenza <ul>
ngomaka -osuselwe, njengoba kuboniswe ngenhla, noma nganoma iyiphi imakhaphu ethi "zigoqe ngokwakho". Qaphela ukuthi uma usebenzisa i- <nav>
, akufanele wengeze kuyo role="tablist"
ngokuqondile, njengoba lokhu kuzokhipha indima yomdabu ye-elementi njengophawu lwendawo yokuzulazula. Esikhundleni salokho, shintshela kwenye into (esibonelweni esingezansi, elula <div>
) bese uyisonga <nav>
.
I-plugin yamathebhu futhi isebenza namaphilisi.
Consequat occaecat ullamco amet non eiusmod nostrud dore irure incididunt est duis anim sunt officia. Fugiat velit proident aliquip nisi incididunt nostrud exercitation proident est nisi. Irure magna elit commodo anim ex veniam culpa eiusmod id nostrud sit cupidatat in veniam ad. I-Eiusmod consequat eu adipisicing minim anim aliquip cupidatat culpa excepteur quis. Occaecat sit eu exercitation 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.
Futhi namaphilisi aqondile.
Cillum ad ut irure tempor velit nostrud occaecat ullamco aliqua anim Lorem sint. Veniam sint duis incididunt do esse magna mollit excepteur laborum qui. Id id reprehenderit sit est eu aliqua occaecat quis et velit excepteur laborum mollit dolore eiusmod. Ipsum dolor in occaecat commodo et voluptate minim reprehenderit mollit pariatur. Deserunt non laborum enim et cillum eu deserunt excepteur ea incididunt minim occaecat.
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.
Using data attributes
You can activate a tab or pill navigation without writing any JavaScript by simply specifying data-toggle="tab"
or data-toggle="pill"
on an element. Use these data attributes on .nav-tabs
or .nav-pills
.
Via JavaScript
Enable tabbable tabs via JavaScript (each tab needs to be activated individually):
You can activate individual tabs in several ways:
Fade effect
To make tabs fade in, add .fade
to each .tab-pane
. The first tab pane must also have .show
to make the initial content visible.
Methods
Asynchronous methods and transitions
All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started but before it ends. In addition, a method call on a transitioning component will be ignored.
$().tab
Activates a tab element and content container. Tab should have either a data-target
or an href
targeting a container node in the DOM.
.tab(‘show’)
Selects the given tab and shows its associated pane. Any other tab that was previously selected becomes unselected and its associated pane is hidden. Returns to the caller before the tab pane has actually been shown (i.e. before the shown.bs.tab
event occurs).
.tab(‘dispose’)
Destroys an element’s tab.
Events
When showing a new tab, the events fire in the following order:
hide.bs.tab
(on the current active tab)show.bs.tab
(on the to-be-shown tab)hidden.bs.tab
(on the previous active tab, the same one as for thehide.bs.tab
event)shown.bs.tab
(on the newly-active just-shown tab, the same one as for theshow.bs.tab
event)
If no tab was already active, then the hide.bs.tab
and hidden.bs.tab
events will not be fired.
Event Type | Description |
---|---|
show.bs.tab | This event fires on tab show, but before the new tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively. |
shown.bs.tab | This event fires on tab show after a tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively. |
hide.bs.tab | This event fires when a new tab is to be shown (and thus the previous active tab is to be hidden). Use event.target and event.relatedTarget to target the current active tab and the new soon-to-be-active tab, respectively. |
hidden.bs.tab | This event fires after a new tab is shown (and thus the previous active tab is hidden). Use event.target and event.relatedTarget to target the previous active tab and the new active tab, respectively. |