Navs
Takaddun bayanai da misalai na yadda ake amfani da abubuwan haɗin kewayawa na Bootstrap.
Ana samun kewayawa a cikin Bootstrap rabo na gaba ɗaya da salo, daga .nav
ajin tushe zuwa jihohi masu aiki da nakasassu. Musanya azuzuwan masu gyara don canzawa tsakanin kowane salo.
An .nav
gina sashin tushe tare da flexbox kuma yana ba da tushe mai ƙarfi don gina kowane nau'ikan abubuwan kewayawa. Ya haɗa da wasu juyewar salo (don aiki tare da jeri), wasu fakitin hanyar haɗin gwiwa don manyan wuraren da aka buga, da salo na nakasassu na asali.
Bangaren tushe .nav
bai haɗa da kowace .active
jiha ba. Misalai masu zuwa sun haɗa da ajin, musamman don nuna cewa wannan ajin ba ya haifar da wani salo na musamman.
<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>
Ana amfani da azuzuwan gaba ɗaya, don haka alamar ku na iya zama mai sassauƙa sosai. Yi amfani <ul>
da s kamar na sama, ko mirgine naku tare da faɗi wani <nav>
abu. Saboda .nav
amfanin display: flex
, hanyoyin haɗin nav suna yin daidai da abubuwan nav, amma ba tare da ƙarin alamar ba.
<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>
Canja salon .nav
bangaren s tare da masu gyara da abubuwan amfani. Mix da daidaita yadda ake buƙata, ko gina naku.
Canja jeri a kwance na nav ɗinku tare da kayan aikin flexbox . Ta hanyar tsoho, navs suna daidaitawa zuwa hagu, amma zaka iya canza su cikin sauƙi zuwa tsakiya ko masu layi na dama.
A tsakiya tare da .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>
Daidaitacce tare da .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>
Tari kewayawar ku ta hanyar canza jagorar abu mai sassauƙa tare da .flex-column
mai amfani. Kuna buƙatar tara su akan wasu wuraren kallo amma ba wasu ba? Yi amfani da nau'ikan amsawa (misali, .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>
Kamar koyaushe, kewayawa tsaye yana yiwuwa ba tare <ul>
da s ba, kuma.
<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>
Yana ɗaukar maɓallin kewayawa na asali daga sama kuma yana ƙara .nav-tabs
ajin don samar da abin dubawa na tabbed. Yi amfani da su don ƙirƙirar yankuna masu iya aiki tare da shafin mu JavaScript plugin .
<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>
Ɗauki HTML iri ɗaya, amma amfani .nav-pills
maimakon:
<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>
Tilasta .nav
abubuwan da ke cikin ku don tsawaita cikakken faɗin samuwa ɗaya daga cikin azuzuwan masu gyara guda biyu. Don cika duk sararin samaniya daidai da .nav-item
s ɗin ku, yi amfani da .nav-fill
. Lura cewa duk sararin samaniya an mamaye shi, amma ba kowane abu na jirgin ruwa ne yake da faɗi ɗaya ba.
<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>
Lokacin amfani da <nav>
tushen kewayawa, tabbatar da haɗawa .nav-item
akan anka.
<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>
Don abubuwa masu faɗi daidai, yi amfani da .nav-justified
. Duk sararin samaniyar da ke kwance za a shagaltar da su ta hanyar haɗin yanar gizo, amma ba kamar na .nav-fill
sama ba, kowane abu na nav zai zama faɗi ɗaya.
<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>
Mai kama da .nav-fill
misalin ta amfani da <nav>
maɓallin kewayawa na tushen, tabbas kun haɗa .nav-item
akan anka.
<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>
Idan kuna buƙatar bambance-bambancen kewayawa mai amsawa, yi la'akari da yin amfani da jerin kayan aikin flexbox . Yayin da karin magana, waɗannan abubuwan amfani suna ba da gyare-gyare mafi girma a duk wuraren faɗuwa. A cikin misalin da ke ƙasa, za a jera nav ɗin mu akan mafi ƙanƙanta wurin hutu, sa'an nan kuma ya dace da shimfidar shimfidar wuri wanda ke cike faɗuwar da ke akwai wanda ya fara daga ƙaramin wurin hutu.
<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>
Idan kana amfani da navs don samar da sandar kewayawa, tabbatar da ƙara role="navigation"
zuwa mafi madaidaicin kwantena na iyaye na <ul>
, ko kunsa wani <nav>
abu a kewayen gabaɗayan kewayawa. Kada a ƙara rawar ga <ul>
kanta, saboda wannan zai hana a sanar da shi a matsayin ainihin jeri ta hanyar fasahar taimako.
Lura cewa sandunan kewayawa, ko da an tsara su ta gani azaman shafuka tare da .nav-tabs
ajin, bai kamata a ba role="tablist"
, role="tab"
ko role="tabpanel"
sifofi ba. Waɗannan sun dace ne kawai don musaya masu tsauri, kamar yadda aka bayyana a cikin Ayyukan Marubuci na WAI ARIA . Dubi halayen JavaScript don mu'amala mai ƙarfi a cikin wannan sashe don misali.
Ƙara menu na zaɓuka tare da ɗan ƙarin HTML da abubuwan da aka sauke JavaScript plugin .
<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>
Yi amfani da shafin JavaScript plugin-haɗa shi ɗaiɗaiku ko ta hanyar bootstrap.js
fayil ɗin da aka haɗe-don tsawaita shafukan mu na kewayawa da kwaya don ƙirƙirar fanatin abubuwan ciki na gida, ko da ta menu na zaɓuka.
Idan kuna gina JavaScript ɗin mu daga tushe, yana buƙatarutil.js
.
Ƙwararrun hanyoyin haɗin yanar gizo, kamar yadda aka bayyana a cikin Ayyukan Marubuta na WAI ARIA , suna buƙatar role="tablist"
, role="tab"
, role="tabpanel"
, da ƙarin aria-
sifofi don isar da tsarin su, ayyukansu da halin yanzu ga masu amfani da fasahar taimako (kamar masu karanta allo).
Lura cewa musaya mai ƙarfi bai kamata ya ƙunshi menus na zazzagewa ba, saboda wannan yana haifar da abubuwan amfani da dama. Daga hangen nesa mai amfani, gaskiyar cewa abin da ake nunawa shafin a halin yanzu ba a iya gani nan da nan (kamar yadda yake cikin rufaffiyar menu) na iya haifar da rudani. Daga mahangar samun dama, a halin yanzu babu wata hanya mai ma'ana don taswirar irin wannan ginin zuwa daidaitaccen tsarin WAI ARIA, ma'ana cewa ba za a iya fahimtar da shi cikin sauƙi ga masu amfani da fasahar taimako ba.
Raw denim tabbas ba ku ji labarin su jeans shorts Austin ba. Nesciunt tofu stumptown aliqua, retro synth master cleanse. gashin baki cliche tempor, williamsburg carles vegan helvetica. Reprehenderit mahauci retro keffiyeh dreamcatcher synth. Cosby suwaita eu banh mi, qui irure terry richardson ex squid. Yadda ake yin salvia cillum iphone. Seitan aliquip quis cardigan Amurka tufafi, mahauta 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.
Don taimakawa dacewa da buƙatun ku, wannan yana aiki tare da <ul>
tushen alamar alama, kamar yadda aka nuna a sama, ko tare da kowane alamar “mirgina naku” na sabani. Lura cewa idan kana amfani da <nav>
, bai kamata ka ƙara role="tablist"
kai tsaye zuwa gare shi ba, saboda wannan zai ƙetare aikin ɗan ƙasa a matsayin alamar kewayawa. Madadin haka, canza zuwa wani zaɓi (a cikin misalin da ke ƙasa, mai sauƙi <div>
) kuma kunsa <nav>
kewaye da shi.
Abubuwan plugin ɗin shafuka kuma suna aiki tare da kwayoyi.
Consequat occaecat ullamco amet non eiusmod nostrud dolore irure incididunt est duis anim sunt officia. Fugiat velit bayyananne aliquip nisi inciddunt nostrud exercitation 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 inciddunt 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.
Kuma da kwayoyi na tsaye.
Ci gaba da kasancewa a cikin ɗan gajeren lokaci ba tare da la'akari da yadda ake yin amfani da Lorem ba. Veniam ba za a iya yin la'akari da magna mollit ban da aiki. Id id rerehenderit sit est eu aliqua occaecat quis and velit excepteur laborum mollit dolore eiusmod. Ipsum dolor in occaecat commodo et voluptate minim reprehenderit mollit pariatur. Ba a yi la'akari da abubuwan da ba su da kyau da kuma cillum eu deserunt banda ea inciddunt 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.
Kuna iya kunna shafi ko kewayawa kwaya ba tare da rubuta kowane JavaScript ba ta hanyar tantancewa kawai data-toggle="tab"
ko data-toggle="pill"
akan wani abu. Yi amfani da waɗannan sifofin bayanan akan .nav-tabs
ko .nav-pills
.
Kunna shafukan da za a iya amfani da su ta hanyar JavaScript (kowane shafin yana buƙatar kunna shi daban):
Kuna iya kunna shafuka guda ɗaya ta hanyoyi da yawa:
Don sanya shafuka su shuɗe, ƙara .fade
zuwa kowane .tab-pane
. Rukunin shafin farko kuma dole ne ya .show
sanya abun cikin farko a bayyane.
Hanyoyi masu daidaitawa da canji
Duk hanyoyin API ba daidai ba ne kuma suna fara canji . Suna komawa ga mai kiran da zarar an fara canji amma kafin ya ƙare . Bugu da ƙari, za a yi watsi da kiran hanya akan ɓangaren canji .
Yana kunna abun shafi da kwandon abun ciki. Tab ya kamata ya kasance yana da ko dai data-target
ko wani href
kumburin kwantena mai niyya a cikin DOM.
Yana zaɓar shafin da aka bayar kuma yana nuna aikin haɗin gwiwa. Duk wani shafin da aka zaɓa a baya ya zama ba a zaɓa ba kuma ana ɓoye abin da ke tattare da shi. Komawa ga mai kira kafin a nuna ainihin ɓangaren shafin (watau kafin shown.bs.tab
abin ya faru).
Yana lalata shafin wani abu.
Lokacin nuna sabon shafin, abubuwan da suka faru sun yi wuta a cikin tsari mai zuwa:
hide.bs.tab
(a kan shafin mai aiki na yanzu)show.bs.tab
(a kan shafin da za a nuna)hidden.bs.tab
(akan shafin da ya gabata mai aiki, iri ɗaya da nahide.bs.tab
taron)shown.bs.tab
(akan sabon shafin da aka nuna, iri ɗaya da nashow.bs.tab
taron)
Idan babu shafin da ya riga ya fara aiki, to ba za a kori abubuwan hide.bs.tab
da abubuwan da suka faru ba.hidden.bs.tab
Nau'in Taron | Bayani |
---|---|
nuna.bs.tab | Wannan taron yana gobara akan nunin shafin, amma kafin a nuna sabon shafin. Yi amfani event.target da event.relatedTarget niyya shafi mai aiki da shafin da ya gabata (idan akwai) bi da bi. |
nuna.bs.tab | Wannan taron yana gobara akan nunin shafin bayan an nuna shafin. Yi amfani event.target da event.relatedTarget niyya shafi mai aiki da shafin da ya gabata (idan akwai) bi da bi. |
boye.bs.tab | Wannan taron yana kunna wuta lokacin da za a nuna sabon shafin (don haka za a ɓoye shafin da ya gabata). Yi amfani event.target da event.relatedTarget niyya shafi mai aiki na yanzu da sabon shafin da za a yi aiki nan ba da jimawa ba, bi da bi. |
boye.bs.tab | Wannan taron yana gobara bayan an nuna sabon shafin (saboda haka shafin da ya gabata yana ɓoye). Yi amfani event.target da event.relatedTarget niyya shafi na baya mai aiki da sabon shafin mai aiki, bi da bi. |