Mikanda mpe bandakisa mpo na ndenge ya kosalela biloko ya mobembo oyo ezali na kati ya Bootstrap.

Base nav

Navigation oyo ezali na Bootstrap ekabolaka marquage général mpe ba styles, kobanda na .navclasse ya base tii na ba états actifs mpe désactivés. Swap ba classes ya modificateur pona ko changer entre style moko na moko.

Composante ya base .navetongami na flexbox mpe epesaka fondation makasi mpo na kotonga ba composants ya navigation ya ndenge nionso. Ezali na mwa ba overrides ya style (mpo na kosala na ba liste), mwa padding ya lien mpo na ba zones ya hit ya minene, mpe styling ya base désactivé.

Composante ya base .navezali na .activeétat moko te. Ba exemples oyo elandi ezali na classe, surtout pona kolakisa que classe oyo particulière e déclencher ata styling moko ya spécial te.
<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>

Ba classes esalemaka na mobimba, donc marquage na yo ekoki kozala super flexible. Salelá <ul>s lokola oyo ezali likoló, <ol>soki molongo ya biloko na yo ezali na ntina, to rouler oyo ya yo moko na <nav>élément moko. Po ba .navusages display: flex, ba liens nav ezo comporter ndenge moko na ba éléments nav elingaki, mais sans marquage supplémentaire.

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

Ba styles oyo ezali

Bobongola style ya .navcomposant s na ba modificateurs na ba utilitaires. Sangisa mpe kosangisa soki esengeli, to tonga oyo ya yo moko.

Alignment ya horizontal

Bobongola alignment horizontal ya nav na yo na ba utilitaires flexbox . Par défaut, ba navs ezali aligné na gauche, kasi okoki ko changer yango facilement na aligné na centre to na droite.

Ezali na centre na .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>

Ezali na boyokani na lobɔkɔ ya mobali na .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>

Ya kotelema

Stack navigation na yo na ko changer direction ya flex item na .flex-columnutilitaire. Besoin ya ko empiler bango na ba viewports mosusu mais misusu te? Salelá ba versions oyo ezo répondre (ndakisa,.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>

Comme toujours, navigation verticale ezali possible sans<ul> s, trop.

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

Ba onglets

Azuaka nav ya base depuis likolo pe abakisi .nav-tabsclasse pona ko produire interface ya onglet. Salelá yango mpo na kosala ba régions ya ba tabbables na plugin na biso ya JavaScript ya tab .

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

Ba pilili

Zwá kaka HTML yango, kasi salelá .nav-pillsna esika na yango:

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

Tondisa mpe kolongisa

Forcer .navba contenus ya yo 's mpo na ko extend largeur mobimba oyo ezali moko ya ba classes mibale ya modificateur. Mpo na kotondisa na ndenge oyo ebongi bisika nyonso oyo ezali na .nav-items na yo, salelá .nav-fill. Simbá ete esika nyonso ya horizontal ezali occupé, kasi eloko nyonso ya nav ezali na bonene ndenge moko te.

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

Ntango ozali kosalela <nav>navigation -based, okoki kotika na kimia .nav-itemlokola kaka .nav-linkesengeli mpo na ba <a>éléments ya styling.

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

Mpo na biloko oyo ezali na bonene ekokani, salelá .nav-justified. Espace horizontal nionso ekozala occupé na ba liens nav, mais na bokeseni na oyo ya .nav-filllikolo, eloko nionso ya nav ekozala na largeur moko.

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

Ndenge moko na .nav-fillndakisa oyo esalelaka <nav>navigation oyo esalemi na -.

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

Kosala na ba utilitaires flex

Soki ozali na mposa ya ba variations nav oyo ezo répondre, kanisá kosalela série ya ba utilitaires ya flexbox . Atako ezali verbose mingi, ba utilitaires oyo epesaka personnalisation monene na kati ya ba points de rupture oyo ezo répondre. Na ndakisa oyo ezali awa na nse, nav na biso ekozala ebele na point de rupture ya nse, sima ko adapter na disposition horizontale oyo etondisaka largeur oyo ezali kobanda na point de rupture ya moke.

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

Na oyo etali accessibilité

Soki ozali kosalela navs mpo na kopesa barre ya navigation, sala makasi obakisa a role="navigation"na conteneur parent oyo ezali na logique mingi ya <ul>, to envelopper <nav>élément moko zingazinga ya navigation mobimba. Kobakisa te rôle na <ul>yango moko, mpo yango ekopekisa yango esakolama lokola liste ya solosolo na ba technologies ya kosunga.

Yeba ete ba barres ya navigation, ata soki esalemi na ndenge ya komona lokola ba onglets na .nav-tabsclasse, esengeli te kopesama role="tablist", role="tab"to role="tabpanel"ba attributs. Yango ebongi kaka mpo na ba interfaces ya ba onglets dynamiques, ndenge elobami na modèle ya ba onglets ya Guide ya Mimeseno ya Bokomi ya ARIA . Tala bizaleli ya JavaScript mpo na ba interfaces ya ba onglets dynamiques na eteni oyo mpo na ndakisa.

Kosalela ba dropdowns

Bakisa ba menu oyo ezali kokita na mwa HTML ya kobakisa mpe ba plugin ya JavaScript oyo ezali kokita .

Ba onglets na ba 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>

Ba pilili na ba 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>

Etamboli ya JavaScript

Salelá tab JavaScript plugin —kɔtisá yango mokomoko to na nzela ya oyo esangisibootstrap.js fisyé oyo esangisi —mpo na koyeisa monene ba onglets mpe ba pilili na biso ya navigation mpo na kosala ba panneaux ya ba tabbables ya makambo ya esika.

Soki ozali kotonga JavaScript na biso uta na source, esengakautil.js .

Ba interfaces ya ba onglets dynamiques, ndenge elobami na modèle ya ba onglets ya Guide des pratiques d’auteur ya ARIA , esengaka role="tablist", role="tab", role="tabpanel", mpe ba aria-attributs ya kobakisa mpo na kopesa structure na yango, fonctionnalité mpe état actuel na basaleli ya ba technologies ya lisungi (lokola ba lecteurs d’écran). Lokola momeseno malamu, tozali kopesa toli ya kosalela <button>biloko mpo na ba onglets, lokola yango ezali ba contrôles oyo e déclencher changement dynamique, na esika ya ba liens oyo ezo naviguer na page to esika ya sika.

Yeba ete plugin ya JavaScript ya onglet esimbaka te ba interfaces ya onglet oyo ezali na ba menu oyo ezali kokita, mpamba te yango epesaka mikakatano ya kosalela mpe ya kozwa yango. Na perspective ya usabilité, le fait que élément déclencheur ya onglet oyo elakisami sikoyo emonanaka mbala moko te (lokola ezali na kati ya menu déroulant fermé) ekoki kosala confusion. Na point de vue ya accessibilité, ezali na tango oyo na moyen sensible te ya kosala carte ya lolenge oyo ya construction na modèle standard WAI ARIA, elingi koloba ete ekoki kozala facilement te kozala compréhensible na ba usagers ya ba technologies d’assistance.

Contenu ya placeholder pona panneau ya onglet. Oyo ezali na boyokani na tab ya ndako. Ezali komema yo bakilomɛtrɛ likoló, likoló mpenza, mpo azali na mwa kosɛka wana moko ya mokili mobimba. Mopaya moko azali na mbeto na ngai, ezali na kobɛtabɛta na motó na ngai. Oh, te. Na vie mosusu nalingaki nasala que otikala. 'Po ngai, nazali capable ya eloko nionso. Kobongisa mpo na etumba na ngai ya kozwa motole. Ozalaki koyiba masanga ya baboti na yo mpe komata na toit. Tone, tan fit mpe prêt, kobalusa yango likolo cause ya gettin' kilo. Bolingo na ye ezali lokola nkisi. Nakanisi ete nabosanaki ete nazalaki na likambo ya kopona.

Contenu ya placeholder pona panneau ya onglet. Oyo ezali na boyokani na onglet ya profil. Ozwi architecture ya malamu koleka. Ba timbres ya passeport, azali cosmopolite. Fine, fresh, fierce, tozwaki yango na serrure. Jamais planifié que un jour nakozala ko perdre yo. Aliaka motema na yo libanda. Ba bisous na yo eza cosmique, mouvement nionso eza magie. Nalingi koloba ba oyo, nalingi koloba lokola ye nde mutu. Mbote balingami tosala mobembo. Kaka propriétaire ya butu lokola le 4 juillet! Kasi okolinga kobeba mpamba.

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>

Mpo na kosalisa na kokokana na bamposa na yo, yango esalaka na <ul>-basé na bilembo, lokola emonisami awa na likoló, to na bilembo nyonso ya “kobalusa ya yo moko” oyo esalemi na ndenge ya arbitraire. Yeba ete soki ozali kosalela <nav>, osengeli te kobakisa role="tablist"mbala moko na yango, mpamba te yango ekolongola mokumba ya mboka ya eleman lokola elembo ya botali. Na esika ya kosala bongo, bongola na eloko mosusu (na ndakisa oyo ezali awa na nse, eloko moko ya pɛtɛɛ <div>) mpe zingá yango <nav>zingazinga na yango.

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

Plugin ya ba onglets esalaka pe na ba pilili.

Contenu ya placeholder pona panneau ya onglet. Oyo ezali na boyokani na tab ya ndako. Ezali komema yo bakilomɛtrɛ likoló, likoló mpenza, mpo azali na mwa kosɛka wana moko ya mokili mobimba. Mopaya moko azali na mbeto na ngai, ezali na kobɛtabɛta na motó na ngai. Oh, te. Na vie mosusu nalingaki nasala que otikala. 'Po ngai, nazali capable ya eloko nionso. Kobongisa mpo na etumba na ngai ya kozwa motole. Ozalaki koyiba masanga ya baboti na yo mpe komata na toit. Tone, tan fit mpe prêt, kobalusa yango likolo cause ya gettin' kilo. Bolingo na ye ezali lokola nkisi. Nakanisi ete nabosanaki ete nazalaki na likambo ya kopona.

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>

Mpe na bankisi oyo ezali semba.

Contenu ya placeholder pona panneau ya onglet. Oyo ezali na boyokani na tab ya ndako. Namonaki yo na centre-ville koyemba ba Blues. Botala ndenge osala cercle na drain. Mpo na nini ozali kotika ngai te ete natika? Kilo ezali motó oyo elataka motole. Ɛɛ, tozali koganga baanzelu, kobɛtaka mbula na mabelé longwa na likoló. Wanna komona émission na 3D, film moko. Est-ce que oyokaka jamais, oyokaka tellement papier mince. Ezali ɛɛ to te, te mbala mosusu.

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>

Kosalela ba attributs ya ba données

Okoki ko activer navigation ya onglet to ya pilili sans kokoma JavaScript moko te na ko préciser kaka data-toggle="tab"to data-toggle="pill"na élément moko. Salelá bizaleli oyo ya ba données na .nav-tabsto .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>

Na nzela ya JavaScript

Activer ba onglets ya ba tabbables na nzela ya JavaScript (onglet moko na moko esengeli ko activer yango moko):

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

Okoki ko activer ba onglets moko moko na ba façons ebele:

$('#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

Effet ya kosila

Mpo na kosala ete ba onglets esila, bakisá .fademoko na moko .tab-pane. Panneau ya onglet ya liboso esengeli mpe kozala .showna kosala ete makambo ya ebandeli emonanaka.

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

Ba méthodes ya kosala

Ba méthodes asynchrones na ba transitions

Ba méthodes nionso ya API ezali asynchrone mpe ebandi transition . Bazongaka epai ya moto oyo abengi ntango kaka mbongwana ebandi kasi liboso ete esila . En plus, appel ya méthode na composante ya transition ekozala ignorée .

Tala mikanda na biso ya JavaScript mpo na koyeba makambo mosusu .

$().tab

Ezali ko activer élément ya onglet na conteneur ya contenus. Onglet esengeli kozala na soit data-targetto, soki ozali kosalela lien, hrefattribut oyo ezali ko cibler node ya conteneur na 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('lakisa') .

Pona tab oyo epesami mpe elakisaka panneau na yango oyo esangisi yango. Onglet mosusu nyonso oyo eponami liboso ekómaka oyo eponami te mpe etanda na yango oyo esangisi yango ebombami. Ezongi na mobengi yambo ete esika ya tab elakisama mpenza (elingi koloba liboso ete shown.bs.tablikambo esalema).

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

.tab('kobwaka')

Ebebisaka tab ya élément moko.

Makambo oyo esalemaki

Ntango ozali kolakisa tab ya sika, makambo yango ekobeta na molɔngɔ oyo elandi:

  1. hide.bs.tab(na tab oyo ezali kosala lelo)
  2. show.bs.tab(na tab oyo esengeli kolakisa)
  3. hidden.bs.tab(na onglet actif ya liboso, ndenge moko na oyo ya hide.bs.tabévénement)
  4. shown.bs.tab(na tab oyo euti kolakisa sika oyo ezali kosala sika, ndenge moko na oyo ya show.bs.tablikambo yango)

Soki onglet moko te ezalaki déjà activé, alors ba événements hide.bs.tabmpe hidden.bs.tabekobeta te.

Lolenge ya likambo Ndimbola
lakisa.bs.tab Evenement oyo ezo beta na tab show, mais avant onglet ya sika elakisama. Salelá event.targetmpe mpo na event.relatedTargetko cibler onglet active mpe onglet active ya kala (soki ezali) respectivement.
elakisami.bs.tab Evenement oyo ezo beta na tab show sima ya tab moko elakisama. Salelá event.targetmpe mpo na event.relatedTargetko cibler onglet active mpe onglet active ya kala (soki ezali) respectivement.
bomba.bs.tab Evenement oyo ezo beta tango onglet ya sika esengeli kolakisa (et donc onglet actif ya kala esengeli kobombama). Salelá event.targetmpe event.relatedTargetmpo na kopesa motuya na tab oyo ezali kosala sikoyo mpe onglet ya sika oyo ekosalema kala mingi te, na kolanda.
ebombami.bs.tab Evenement oyo ezo beta sima ya onglet ya sika elakisami (mpe bongo onglet actif ya kala ebombami). Salelá event.targetmpe mpo na event.relatedTargetko cibler onglet active ya kala mpe onglet active ya sika, respectivement.
$('button[data-toggle="tab"]').on('shown.bs.tab', function (event) {
  event.target // newly activated tab
  event.relatedTarget // previous active tab
})