Dokumentazzjoni u eżempji ta' kif tuża l-komponenti ta' navigazzjoni inklużi ta' Bootstrap.

Base nav

In-navigazzjoni disponibbli f'Bootstrap jaqsmu markup ġenerali u stili, mill- .navklassi bażi għall-istati attivi u b'diżabilità. Ibdel il-klassijiet tal-modifikatur biex taqleb bejn kull stil.

Il- .navkomponent bażi huwa mibni bil-flexbox u jipprovdi pedament b'saħħtu għall-bini ta 'kull tip ta' komponenti ta 'navigazzjoni. Jinkludi xi stil overrides (għal ħidma ma 'listi), xi link padding għal żoni akbar hit, u stil bażiku b'diżabilità.

Il- .navkomponent bażi ma jinkludi l-ebda .activestat. L-eżempji li ġejjin jinkludu l-klassi, prinċipalment biex juru li din il-klassi partikolari ma tagħtix bidu għal xi stil speċjali.
<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">Disabled</a>
  </li>
</ul>

Il-klassijiet jintużaw tul, għalhekk il-markup tiegħek jista 'jkun super flessibbli. Uża <ul>s bħal hawn fuq, <ol>jekk l-ordni tal-oġġetti tiegħek hija importanti, jew irrombla tiegħek <nav>b'element. Minħabba li l- .navużi display: flex, il-links tan-nav iġibu ruħhom l-istess bħall-oġġetti tan-nav, iżda mingħajr il-markup żejjed.

<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">Disabled</a>
</nav>

Stili disponibbli

Ibdel l-istil tal .nav-komponent s b'modifikaturi u utilitajiet. Ħallat u qabbel kif meħtieġ, jew ibni tiegħek.

Allinjament orizzontali

Ibdel l-allinjament orizzontali tan-nav tiegħek b'utilitajiet tal- flexbox . B'mod awtomatiku, in-navs huma allinjati max-xellug, iżda tista 'faċilment tibdelhom lejn iċ-ċentru jew il-lemin.

Iċċentrat ma' .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">Disabled</a>
  </li>
</ul>

Allinjat mal-lemin ma' .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">Disabled</a>
  </li>
</ul>

Vertikali

Stack in-navigazzjoni tiegħek billi tbiddel id-direzzjoni tal-oġġett flex bl- .flex-columnutilità. Għandek bżonn tiġborhom fuq xi viewports iżda mhux oħrajn? Uża l-verżjonijiet li jirrispondu (eż, .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">Disabled</a>
  </li>
</ul>

Bħal dejjem, in-navigazzjoni vertikali hija possibbli mingħajr <ul>s, ukoll.

<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">Disabled</a>
</nav>

Tabs

Jieħu n-nav bażiku minn fuq u żżid il- .nav-tabsklassi biex tiġġenera interface b'tabbed. Użahom biex toħloq reġjuni tabbable bil- plugin tagħna tat-tab JavaScript .

<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">Disabled</a>
  </li>
</ul>

Pilloli

Ħu dak l-istess HTML, imma uża .nav-pillsminflok:

<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">Disabled</a>
  </li>
</ul>

Imla u ġġustifika

Ġigħel il- .navkontenut tiegħek biex jestendi l-wisa 'sħiħ disponibbli waħda minn żewġ klassijiet ta' modifikatur. Biex timla l-ispazju kollu disponibbli b'mod proporzjonali bl- .nav-itemi tiegħek, uża .nav-fill. Innota li l-ispazju orizzontali kollu huwa okkupat, iżda mhux kull oġġett tan-nav għandu l-istess wisa '.

<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="#">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>

Meta tuża <nav>navigazzjoni bbażata fuq, tista 'tħalli barra b'mod sikur .nav-itemkif huwa meħtieġ biss għall- elementi .nav-linktal-grafika .<a>

<nav class="nav nav-pills nav-fill">
  <a class="nav-link active" 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>

Għal elementi ta' wisa' ugwali, uża .nav-justified. L-ispazju orizzontali kollu se jkun okkupat minn links tan-nav, iżda b'differenza .nav-fillminn hawn fuq, kull oġġett tan-nav se jkun l-istess wisa '.

<ul class="nav nav-pills nav-justified">
  <li class="nav-item">
    <a class="nav-link active" 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>

Simili għall- .nav-filleżempju bl-użu ta ' <nav>navigazzjoni bbażata fuq.

<nav class="nav nav-pills nav-justified">
  <a class="nav-link active" 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>

Ħidma ma 'utilitajiet flex

Jekk għandek bżonn varjazzjonijiet tan-nav li jirrispondu, ikkunsidra li tuża serje ta ' utilitajiet tal-flexbox . Filwaqt li huma aktar verbose, dawn l-utilitajiet joffru customization akbar madwar breakpoints li jirrispondu. Fl-eżempju hawn taħt, in-nav tagħna se jkun f'munzelli fuq l-iktar breakpoint baxx, imbagħad jadatta għal tqassim orizzontali li jimla l-wisa 'disponibbli li jibda mill-breakpoint żgħir.

<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="#">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>

Rigward l-aċċessibbiltà

Jekk qed tuża navs biex tipprovdi bar tan-navigazzjoni, kun żgur li żżid role="navigation"mal-kontenitur ġenitur l-aktar loġiku tal- <ul>, jew wrap <nav>element madwar in-navigazzjoni kollha. Iżżidx ir-rwol mal- <ul>persuna nfisha, peress li dan jipprevjeni milli jitħabbar bħala lista attwali minn teknoloġiji ta' assistenza.

Innota li l-vireg tan-navigazzjoni, anki jekk viżwalment stilati bħala tabs mal- .nav-tabsklassi, m'għandhomx jingħataw role="tablist", role="tab"jew role="tabpanel"attributi. Dawn huma xierqa biss għal interfaces b'tabbed dinamiċi, kif deskritt fil- mudell ta' tabs tal-Gwida tal-Prattiċi tal-Awtur tal-ARIA . Ara l-imġiba JavaScript għal interfaces b'tabbed dinamiċi f'din it-taqsima għal eżempju.

Bl-użu dropdowns

Żid menus dropdown bi ftit HTML żejjed u l- plugin JavaScript dropdowns .

Tabs bi dropdowns

<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-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">Disabled</a>
  </li>
</ul>

Pilloli bi dropdowns

<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-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">Disabled</a>
  </li>
</ul>

Imġieba JavaScript

Uża t-tab JavaScript plugin—inkludih individwalment jew permezz tal- bootstrap.jsfajl ikkumpilat—biex testendi t-tabs u l-pilloli tan-navigazzjoni tagħna biex toħloq panewijiet tabbable ta' kontenut lokali.

Jekk qed tibni JavaScript tagħna mis-sors, teħtieġutil.js .

Interfaces b'tabbed dinamiċi, kif deskritti fil- mudell ta' tabs tal-Gwida tal-Prattiċi tal-Awtur ARIA , jeħtieġu role="tablist", role="tab", role="tabpanel", u aria-attributi addizzjonali sabiex iwasslu l-istruttura, il-funzjonalità u l-istat attwali tagħhom lill-utenti ta' teknoloġiji ta' assistenza (bħal screen readers). Bħala l-aħjar prattika, nirrakkomandaw li tuża <button>elementi għat-tabs, peress li dawn huma kontrolli li jikkawżaw bidla dinamika, aktar milli links li jinnavigaw għal paġna jew post ġdid.

Innota li t-tab JavaScript plugin ma jappoġġjax interfejs b'tabbed li fihom menus dropdown, peress li dawn jikkawżaw kemm kwistjonijiet ta 'użabilità kif ukoll ta' aċċessibbiltà. Mill-perspettiva tal-użabilità, il-fatt li l-element grillu tat-tab murija bħalissa mhux viżibbli immedjatament (għaliex huwa ġewwa l-menu dropdown magħluq) jista 'jikkawża konfużjoni. Mil-lat ta' aċċessibbiltà, bħalissa m'hemm l-ebda mod sensibbli biex din it-tip ta' kostruzzjoni tiġi mmappjata għal mudell WAI ARIA standard, li jfisser li ma jistax jinftiehem faċilment mill-utenti ta 'teknoloġiji ta' assistenza.

Kontenut tal-post għall-pannell tat-tab. Din tirrigwarda t-tab tad-dar. Jieħdok mili għoli, daqshekk għoli, għax għandha dik it-tbissima internazzjonali waħda. Hemm barrani fis-sodda tiegħi, hemm taħbit f’rasi. Oh, le. F'ħajja oħra kont inġiegħlek toqgħod. Għax jien kapaċi għal kollox. Suiding up għall-battalja kuruna tiegħi. Użat biex tisraq il-likur tal-ġenituri tiegħek u titla’ fuq il-bejt. Ton, tan tajjeb u lest, dawwar it up kawża tagħha gettin' tqil. L-imħabba tagħha hija bħal droga. Naħseb li insejt li kelli għażla.

Kontenut tal-post għall-pannell tat-tab. Din hija relatata mat-tab tal-profil. Int sibt l-aqwa arkitettura. Bolol tal-passaporti, hi kożmopolitana. Fine, frisk, ħarxa, aħna ltqajna fuq lock. Qatt ma ppjanajt li xi darba nkun qed nitlifkom. Hi tiekol qalbek barra. Il-bewsa tiegħek hija kożmika, kull mossa hija maġija. Jiġifieri dawk, irrid ngħid bħal hi l-waħda. Tislijiet maħbubin ejja nieħdu vjaġġ. Just stess il-lejl bħall-4 ta 'Lulju! Imma tippreferi tinħela.

Placeholder content for the tab panel. This one relates to the contact tab. Her love is like a drug. All my girls vintage Chanel baby. Got a motel and built a fort out of sheets. 'Cause she's the muse and the artist. (This is how we do) So you wanna play with magic. So just be sure before you give it all to me. I'm walking, I'm walking on air (tonight). Skip the talk, heard it all, time to walk the walk. Catch her if you can. Stinging like a bee I earned my stripes.

<ul class="nav nav-tabs" id="myTab" role="tablist">
  <li class="nav-item" role="presentation">
    <button class="nav-link active" id="home-tab" data-toggle="tab" data-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-toggle="tab" data-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-toggle="tab" data-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>

Biex tgħin jaqbel mal-bżonnijiet tiegħek, dan jaħdem <ul>b'markup ibbażat fuq -, kif muri hawn fuq, jew bi kwalunkwe markup arbitrarju "roll your own". Innota li jekk qed tuża <nav>, m'għandekx iżżid role="tablist"direttament miegħu, peress li dan jegħleb ir-rwol nattiv tal-element bħala punt ta' referenza tan-navigazzjoni. Minflok, aqleb għal element alternattiv (fl-eżempju hawn taħt, sempliċi <div>) u wrap <nav>madwaru.

<nav>
  <div class="nav nav-tabs" id="nav-tab" role="tablist">
    <button class="nav-link active" id="nav-home-tab" data-toggle="tab" data-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-toggle="tab" data-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-toggle="tab" data-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>

Il-plugin tat-tabs jaħdem ukoll bil-pilloli.

Kontenut tal-post għall-pannell tat-tab. Din tirrigwarda t-tab tad-dar. Jieħdok mili għoli, daqshekk għoli, għax għandha dik it-tbissima internazzjonali waħda. Hemm barrani fis-sodda tiegħi, hemm taħbit f’rasi. Oh, le. F'ħajja oħra kont inġiegħlek toqgħod. Għax jien kapaċi għal kollox. Suiding up għall-battalja kuruna tiegħi. Użat biex tisraq il-likur tal-ġenituri tiegħek u titla’ fuq il-bejt. Ton, tan tajjeb u lest, dawwar it up kawża tagħha gettin' tqil. L-imħabba tagħha hija bħal droga. Naħseb li insejt li kelli għażla.

Placeholder content for the tab panel. This one relates to the profile tab. You got the finest architecture. Passport stamps, she's cosmopolitan. Fine, fresh, fierce, we got it on lock. Never planned that one day I'd be losing you. She eats your heart out. Your kiss is cosmic, every move is magic. I mean the ones, I mean like she's the one. Greetings loved ones let's take a journey. Just own the night like the 4th of July! But you'd rather get wasted.

Placeholder content for the tab panel. This one relates to the contact tab. Her love is like a drug. All my girls vintage Chanel baby. Got a motel and built a fort out of sheets. 'Cause she's the muse and the artist. (This is how we do) So you wanna play with magic. So just be sure before you give it all to me. I'm walking, I'm walking on air (tonight). Skip the talk, heard it all, time to walk the walk. Catch her if you can. Stinging like a bee I earned my stripes.

<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-toggle="pill" data-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-toggle="pill" data-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-toggle="pill" data-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>

U b'pilloli vertikali.

Kontenut tal-post għall-pannell tat-tab. Din tirrigwarda t-tab tad-dar. Rajtek downtown tkanta l-Blues. Ara inti ċirku l-fossa. Għaliex ma tħallinix nieqaf? Tqila hija r-ras li tilbes il-kuruna. Iva, nagħmlu l-anġli jibku, ix-xita fuq l-art minn fuq. Trid tara l-ispettaklu fi 3D, film. Qatt tħossok, tħossok daqshekk irqiq tal-karta. Huwa iva jew le, le forsi.

Placeholder content for the tab panel. This one relates to the profile tab. Takes you miles high, so high, 'cause she’s got that one international smile. There's a stranger in my bed, there's a pounding in my head. Oh, no. In another life I would make you stay. ‘Cause I, I’m capable of anything. Suiting up for my crowning battle. Used to steal your parents' liquor and climb to the roof. Tone, tan fit and ready, turn it up cause its gettin' heavy. Her love is like a drug. I guess that I forgot I had a choice.

Placeholder content for the tab panel. This one relates to the messages tab. You got the finest architecture. Passport stamps, she's cosmopolitan. Fine, fresh, fierce, we got it on lock. Never planned that one day I'd be losing you. She eats your heart out. Your kiss is cosmic, every move is magic. I mean the ones, I mean like she's the one. Greetings loved ones let's take a journey. Just own the night like the 4th of July! But you'd rather get wasted.

Placeholder content for the tab panel. This one relates to the settings tab. Her love is like a drug. All my girls vintage Chanel baby. Got a motel and built a fort out of sheets. 'Cause she's the muse and the artist. (This is how we do) So you wanna play with magic. So just be sure before you give it all to me. I'm walking, I'm walking on air (tonight). Skip the talk, heard it all, time to walk the walk. Catch her if you can. Stinging like a bee I earned my stripes.

<div class="row">
  <div class="col-3">
    <div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
      <button class="nav-link active" id="v-pills-home-tab" data-toggle="pill" data-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-toggle="pill" data-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-toggle="pill" data-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-toggle="pill" data-target="#v-pills-settings" type="button" role="tab" aria-controls="v-pills-settings" aria-selected="false">Settings</button>
    </div>
  </div>
  <div class="col-9">
    <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>
</div>

L-użu ta' attributi tad-data

Tista' tattiva tab jew navigazzjoni ta' pillola mingħajr ma tikteb JavaScript billi sempliċement tispeċifika data-toggle="tab"jew data-toggle="pill"fuq element. Uża dawn l-attributi tad-dejta fuq .nav-tabsjew .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-toggle="tab" data-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-toggle="tab" data-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-toggle="tab" data-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-toggle="tab" data-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>

Via JavaScript

Ippermetti tabs tabbable permezz ta' JavaScript (kull tab trid tiġi attivata individwalment):

$('#myTab button').on('click', function (event) {
  event.preventDefault()
  $(this).tab('show')
})

Tista' tattiva tabs individwali b'diversi modi:

$('#myTab button[data-target="#profile"]').tab('show') // Select tab by name
$('#myTab li:first-child button').tab('show') // Select first tab
$('#myTab li:last-child button').tab('show') // Select last tab
$('#myTab li:nth-child(3) button').tab('show') // Select third tab

Effett fade

Biex tagħmel it-tabs fade, żid .fadema 'kull .tab-pane. L-ewwel pannell tat-tab irid ikollu wkoll .showjagħmel il-kontenut inizjali viżibbli.

<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>

Metodi

Metodi asinkroniċi u tranżizzjonijiet

Il-metodi kollha tal-API huma asinkroniċi u jibdew transizzjoni . Jirritornaw għand min iċempel hekk kif tinbeda t-tranżizzjoni iżda qabel ma tispiċċa . Barra minn hekk, sejħa ta' metodu fuq komponent ta' tranżizzjoni se tiġi injorata .

Ara d-dokumentazzjoni JavaScript tagħna għal aktar informazzjoni .

$().tab

Jattiva element tab u kontenitur tal-kontenut. Tab għandu jkollha data-targetjew, jekk tuża link, hrefattribut li jimmira lejn nodu tal-kontenitur fid-DOM.

<ul class="nav nav-tabs" id="myTab" role="tablist">
  <li class="nav-item" role="presentation">
    <button class="nav-link active" id="home-tab" data-toggle="tab" data-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-toggle="tab" data-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-toggle="tab" data-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-toggle="tab" data-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>
  $(function () {
    $('#myTab li:last-child button').tab('show')
  })
</script>

.tab('turi')

Jagħżel it-tab mogħtija u juri l-ħġieġa assoċjata tagħha. Kwalunkwe tab oħra li kienet magħżula qabel issir mhux magħżula u l-ħġieġa assoċjata tagħha hija moħbija. Jirritorna lil min iċempel qabel ma l-panew tat-tab fil-fatt intwera (jiġifieri qabel ma shown.bs.tabjseħħ l-avveniment).

$('#someTab').tab('show')

.tab('armi')

Jeqred tab ta' element.

Avvenimenti

Meta turi tab ġdida, l-avvenimenti jisparaw fl-ordni li ġejja:

  1. hide.bs.tab(fuq it-tab attiva attwali)
  2. show.bs.tab(fuq it-tab li trid tintwera)
  3. hidden.bs.tab(fuq it-tab attiva preċedenti, l-istess bħal għall- hide.bs.tabavveniment)
  4. shown.bs.tab(fuq it-tab li għadha kif intwera, l-istess bħal dik tal- show.bs.tabavveniment)

Jekk l-ebda tab ma kienet diġà attiva, allura l- hide.bs.tabu hidden.bs.tabavvenimenti mhux se jiġu sparati.

Tip ta' Avveniment Deskrizzjoni
juru.bs.tab Dan l-avveniment jispara fuq tab show, iżda qabel ma tkun intweriet it-tab il-ġdida. Uża event.targetu event.relatedTargetbiex timmira t-tab attiva u t-tab attiva preċedenti (jekk disponibbli) rispettivament.
muri.bs.tab Dan l-avveniment jispara fuq tab show wara li tkun intweriet tab. Uża event.targetu event.relatedTargetbiex timmira t-tab attiva u t-tab attiva preċedenti (jekk disponibbli) rispettivament.
hide.bs.tab Dan l-avveniment jispara meta trid tintwera tab ġdida (u għalhekk it-tab attiva preċedenti trid tinħeba). Uża event.targetu event.relatedTargetbiex timmira t-tab attiva attwali u t-tab il-ġdida li dalwaqt tkun attiva, rispettivament.
moħbija.bs.tab Dan l-avveniment jispara wara li tintwera tab ġdida (u għalhekk it-tab attiva preċedenti hija moħbija). Uża event.targetu event.relatedTargetbiex timmira t-tab attiva preċedenti u t-tab attiva l-ġdida, rispettivament.
$('button[data-toggle="tab"]').on('shown.bs.tab', function (event) {
  event.target // newly activated tab
  event.relatedTarget // previous active tab
})