Navs
Amaxwebhu kunye nemizekelo yendlela yokusebenzisa i-Bootstrap equkiweyo yezinto zokukhangela.
Ukukhangela kuyafumaneka kwiBootstrap yabelana ngokuphawulwa ngokubanzi kunye nezimbo, ukusuka kwisiseko .nav
seklasi ukuya kumazwe asebenzayo kunye nabakhubazekileyo. Tshintsha iiklasi zesilungisi ukutshintsha phakathi kwesimbo ngasinye.
Icandelo lesiseko .nav
lakhiwe nge-flexbox kwaye libonelela ngesiseko esomeleleyo sokwakha zonke iintlobo zezixhobo zokuhamba. Ibandakanya ezinye iindlela zokubhala ngaphezulu (zokusebenza ngezintlu), ezinye iikhonkco zekhonkco kwiindawo ezinkulu ezibethayo, kunye nesimbo esisisiseko sabakhubazekileyo.
Icandelo lesiseko .nav
alibandakanyi naliphi na .active
ilizwe. Le mizekelo ilandelayo ibandakanya iklasi, ikakhulu ukubonisa ukuba le klasi ayiqalisi nasiphi na isimbo esikhethekileyo.
<ul class="nav">
<li class="nav-item">
<a class="nav-link active" 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" href="#">Disabled</a>
</li>
</ul>
Iiklasi zisetyenziswa kulo lonke, ngoko uphawu lwakho lunokuba bhetyebhetye kakhulu. Sebenzisa <ul>
s like ngasentla, okanye roll eyakho nge say <nav>
element. Kuba .nav
usebenziso display: flex
, amakhonkco e-nav aziphatha ngendlela efanayo nav izinto eziya kwenza, kodwa ngaphandle kophawulo olongezelelweyo.
<nav class="nav">
<a class="nav-link active" href="#">Active</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled" href="#">Disabled</a>
</nav>
Tshintsha isimbo .nav
s icandelo kunye modifiers kunye eziluncedo. Xuba kwaye utshatise njengoko kufuneka, okanye uzakhele eyakho.
Guqula ulungelelwaniso oluthe tye lwe nav yakho ngezixhobo ze flexbox . Ngokungagqibekanga, ii-navs zilungelelaniswe ekhohlo, kodwa unokuzitshintsha ngokulula zibesembindini okanye zilungelelaniswe ekunene.
Isembindini nge .justify-content-center
:
<ul class="nav justify-content-center">
<li class="nav-item">
<a class="nav-link active" 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" href="#">Disabled</a>
</li>
</ul>
Ilungelelaniswe ekunene ne .justify-content-end
:
<ul class="nav justify-content-end">
<li class="nav-item">
<a class="nav-link active" 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" href="#">Disabled</a>
</li>
</ul>
Gcina ukukhangela kwakho ngokutshintsha isikhokelo sento eguqukayo kunye nezinto .flex-column
eziluncedo. Ngaba kufuneka uzibeke kwezinye iindawo zokujonga kodwa hayi kwezinye? Sebenzisa iinguqulelo eziphendulayo (umz., .flex-sm-column
).
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" 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" href="#">Disabled</a>
</li>
</ul>
Njengesiqhelo, ukukhangela ngokuthe nkqo kunokwenzeka ngaphandle kwe <ul>
-s, kwakhona.
<nav class="nav flex-column">
<a class="nav-link active" href="#">Active</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled" href="#">Disabled</a>
</nav>
Ithatha i-nav esisiseko ukusuka phezulu kwaye yongeza .nav-tabs
iklasi ukuvelisa ujongano olunesithuba. Zisebenzise ukwenza imimandla enokwenzeka ngethebhu yethu iplagi yeJavaScript .
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" 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" href="#">Disabled</a>
</li>
</ul>
Thatha kwaloo HTML inye, kodwa sebenzisa .nav-pills
endaweni yoko:
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" 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" href="#">Disabled</a>
</li>
</ul>
Nyanzelisa .nav
imixholo yakho ukwandisa ububanzi obukhoyo obugcweleyo kwiiklasi ezimbini zesilungisi. Ukugcwalisa ngokulinganayo yonke indawo ekhoyo ngeyakho .nav-item
, sebenzisa .nav-fill
. Qaphela ukuba yonke indawo ethe tye ihleli, kodwa ayizizo zonke izinto ze-nav ezinobubanzi obufanayo.
<ul class="nav nav-pills nav-fill">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">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" href="#">Disabled</a>
</li>
</ul>
Xa usebenzisa i- <nav>
navigation navigation, qiniseka ukuba ubandakanya .nav-item
kwiiankile.
<nav class="nav nav-pills nav-fill">
<a class="nav-item nav-link active" href="#">Active</a>
<a class="nav-item nav-link" href="#">Link</a>
<a class="nav-item nav-link" href="#">Link</a>
<a class="nav-item nav-link disabled" href="#">Disabled</a>
</nav>
Kwizinto ezinobubanzi obulinganayo, sebenzisa .nav-justified
. Zonke isithuba esithe tyaba siya kuhlala ngamakhonkco e-nav, kodwa ngokungafaniyo .nav-fill
nokungasentla, yonke into ye-nav iya kuba nobubanzi obufanayo.
<nav class="nav nav-pills nav-justified">
<a class="nav-link active" href="#">Active</a>
<a class="nav-link" href="#">Longer nav link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled" href="#">Disabled</a>
</nav>
Ngokufana .nav-fill
nomzekelo usebenzisa i- navigation- <nav>
based navigation, qiniseka ukuba uquka .nav-item
kwii-anchors.
<nav class="nav nav-pills nav-justified">
<a class="nav-item nav-link active" href="#">Active</a>
<a class="nav-item nav-link" href="#">Link</a>
<a class="nav-item nav-link" href="#">Link</a>
<a class="nav-item nav-link disabled" href="#">Disabled</a>
</nav>
Ukuba ufuna ukusabela okwahluka kwe-nav, cinga ukusebenzisa uluhlu lwezinto eziluncedo ze- flexbox . Ngelixa i-verbose ngakumbi, ezi zixhobo zibonelela ngokwenziwa ngokwezifiso okukhulu kuzo zonke iindawo ezisabelayo. Kulo mzekelo ungezantsi, i-nav yethu iya kupakishwa kweyona ndawo isezantsi yoqhawulo, emva koko ilungelelanise ubeko oluthe tye olugcwalisa ububanzi obukhoyo ukusuka kwindawo encinci yokuphumla.
<nav class="nav nav-pills flex-column flex-sm-row">
<a class="flex-sm-fill text-sm-center nav-link active" href="#">Active</a>
<a class="flex-sm-fill text-sm-center nav-link" href="#">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" href="#">Disabled</a>
</nav>
Ukuba usebenzisa i-navs ukubonelela ngebar yokukhangela, qiniseka ukuba wongeza role="navigation"
u-a kwesona sikhongozeli sinomzali sinengqiqo se-, <ul>
okanye usonge into ethile kuhambo <nav>
lonke. Musa ukongeza indima kuyo <ul>
ngokwayo, njengoko oku kuya kuthintela ukuba ibhengezwe njengoluhlu lokwenyani ngobuchule bokuncedisa.
Qaphela ukuba iibar zokukhangela, nokuba zibukeka njenge tabhu kunye .nav-tabs
nodidi, akufunekanga zinikwe role="tablist"
, role="tab"
okanye role="tabpanel"
iimpawu. Ezi zilungele kuphela ujongano oluguquguqukayo lwethebhu, njengoko kuchaziwe kwi- WAI ARIA yeZenzo zokuBhalisa . Jonga ukuziphatha kweJavaScript yojongano oluguquguqukayo lwethebhu kweli candelo lomzekelo.
Yongeza iimenu ezihlayo nge-HTML encinci eyongezelelweyo kunye neplagi ye- JavaScript eyehlayo .
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Dropdown</a>
<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>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" href="#">Active</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Dropdown</a>
<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>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
Sebenzisa i-plugin ye-JavaScript yethebhu-yibandakanye ngabanye okanye bootstrap.js
ngefayile ehlanganisiweyo-ukwandisa iithebhu zethu zokuhamba kunye neepilisi ukwenza iipaneli ze-tabhable zesiqulatho sasekhaya, nangeemenyu ezihlayo.
Ukuba wakha iJavaScript yethu kwimvelaphi, kufunautil.js
.
I-Dynamic tabbed interfaces, njengoko ichazwe kwi- WAI ARIA yeZenzo zokuBhalisa , ifuna role="tablist"
, role="tab"
, role="tabpanel"
, kunye neempawu ezongezelelweyo aria-
ukwenzela ukuhambisa isakhiwo sabo, ukusebenza kunye nemeko yangoku kubasebenzisi bobuchwepheshe bokuncedisa (njengabafundi besikrini).
Qaphela ukuba ujongano oluguquguqukayo lwe tab akufuneki luqulathe iimenu ezilahlayo, njengoko oku kubangela zombini ukusetyenziswa kunye nemiba yofikelelo. Ukusuka kwimbono yokusebenziseka, into yokuba isiqalo sethebhu ebonisiweyo ngoku ayibonakali ngokukhawuleza (njengoko ingaphakathi kwimenyu eyehlayo evaliweyo) inokubangela ukubhideka. Ukusuka kumbono wofikelelo, okwangoku akukho ndlela isengqiqweni yokwenza imephu yolu hlobo lolwakhiwo kwipatheni eqhelekileyo ye-WAI ARIA, nto leyo ethetha ukuba ayinakwenziwa lula ukuba iqondeke kubasebenzisi bobuchwephesha bokuncedisa.
Idenim ekrwada mhlawumbi awuzange uve ngabo ibhulukhwe yejean yaseAustin. Nesciunt tofu stumptown aliqua, retro synth master coca. Amadevu cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Ijezi yeCosby eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american iimpahla, 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.
Ukunceda ukulingana neemfuno zakho, oku kusebenza <ul>
ngophawu olusekwe-, njengoko kubonisiwe ngasentla, okanye nangaluphi na uphawu olungenamkhethe "rola okwakho". Qaphela ukuba usebenzisa <nav>
, akufuneki udibanise role="tablist"
ngokuthe ngqo kuyo, njengoko oku kuya kubhala ngaphezulu indima yendalo yesiqalelo njengophawu lokukhangela lomhlaba. Endaweni yoko, tshintshela kwenye into (kumzekelo ongezantsi, elula <div>
) kwaye uyisongele <nav>
ngeenxa zonke.
Iplagi yeethebhu iphinda isebenze kunye neepilisi.
Consequat occaecat ullamco amet non eiusmod nostrud dolore 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. 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.
Kwaye ngeepilisi ezithe nkqo.
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.
Unokwenza ithebhu okanye ujongo lwepilisi ngaphandle kokubhala nayiphi na iJavaScript ngokuchaza ngokulula data-toggle="tab"
okanye data-toggle="pill"
kwinto. Sebenzisa ezi mpawu zedatha kwi .nav-tabs
okanye .nav-pills
.
Yenza iithebhu ezinokubakho ngeJavaScript (ithebhu nganye kufuneka ivulwe ngokwayo):
Unokwenza ithebhu nganye isebenze ngeendlela ezininzi:
Ukwenza iithebhu ziphelelwe, yongeza .fade
kuyo nganye .tab-pane
. Ipheyini yethebhu yokuqala kufuneka kwakhona .show
yenze umxholo wokuqala ubonakale.
Iindlela ze-Asynchronous kunye notshintsho
Zonke iindlela ze-API zi -asynchronous kwaye ziqala utshintsho . Babuyela kumnxeba ngokukhawuleza nje ukuba utshintsho luqalisiwe kodwa ngaphambi kokuba luphele . Ukongeza, ukufowunelwa kwendlela kwicandelo lenguquko kuya kuhoywa .
Yenza isiqalelo sethebhu kunye nesiqulatho sisebenze. Isithuba kufuneka sibenendawo data-target
okanye indawo href
yesikhongozeli kwiDOM.
Ikhetha isithuba esinikiweyo kwaye ibonise isahlulo sayo esinxulumeneyo. Nayiphi enye isithuba ebesikhe yakhethwa ngaphambili ayikhethwanga kwaye isahlulo sayo esinxulumeneyo siyafihlwa. Ibuyisela kumnxebi phambi kokuba ipayini yethebhu iboniswe ngokwenene (okt phambi kokuba shown.bs.tab
isiganeko senzeke).
Uyonakalisa ithebhu yesiqalelo.
Xa ubonisa ithebhu entsha, iziganeko zivutha ngolu hlobo lulandelayo:
hide.bs.tab
(kwithebhu esebenzayo yangoku)show.bs.tab
(kwi-eza kuboniswa thebhu)hidden.bs.tab
(kwithebhu esebenzayo yangaphambili, efanayo nalehide.bs.tab
yesiganeko)shown.bs.tab
(kwisithuba esandula ukusebenza esivele sibonise ithebhu, efanayoshow.bs.tab
nesesiganeko)
Ukuba akukho thebhu ibisele iyasebenza, ngoko i hide.bs.tab
kunye hidden.bs.tab
neziganeko aziyi kugxothwa.
Uhlobo loMnyhadala | Inkcazo |
---|---|
bonisa.bs.tab | Esi siganeko sivutha kumboniso wethebhu, kodwa ngaphambi kokuba ithebhu entsha iboniswe. Sebenzisa event.target kunye event.relatedTarget nokujolisa isithuba esisebenzayo kunye nesithuba sangaphambili esisebenzayo (ukuba sikhona) ngokulandelelanayo. |
ebonisiweyo.bs.tab | Esi siganeko sitshisa kwi-tab show emva kokuba ithebhu ibonisiwe. Sebenzisa event.target kunye event.relatedTarget nokujolisa isithuba esisebenzayo kunye nesithuba sangaphambili esisebenzayo (ukuba sikhona) ngokulandelelanayo. |
fihla.bs.tab | Esi siganeko sitshisa xa isithuba esitsha siza kuboniswa (kwaye ke isithuba sangaphambili esisebenzayo siza kufihlwa). Sebenzisa event.target kunye event.relatedTarget nokujolisa ithebhu esebenzayo yangoku kunye nethebhu entsha eza kusebenza ngokukhawuleza, ngokulandelelanayo. |
efihliweyo.bs.tab | Esi siganeko sivutha emva kokuba ithebhu entsha ibonisiwe (kwaye ke isithuba sangaphambili esisebenzayo sifihliwe). Sebenzisa event.target kunye event.relatedTarget nokujolisa kwithebhu esebenzayo yangaphambili kunye nethebhu entsha esebenzayo, ngokulandelelanayo. |