Kundi la orodha
Vikundi vya orodha ni sehemu inayoweza kunyumbulika na yenye nguvu ya kuonyesha mfululizo wa maudhui. Zirekebishe na zipanue ili kusaidia takriban maudhui yoyote ndani.
Mfano wa msingi
Kikundi cha orodha cha msingi zaidi ni orodha isiyo na mpangilio iliyo na vitu vya orodha na madarasa sahihi. Jenga juu yake na chaguo zinazofuata, au na CSS yako kama inahitajika.
- Kipengee
- Kipengee cha pili
- Kipengee cha tatu
- Kipengee cha nne
- Na ya tano
<ul class="list-group">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
<li class="list-group-item">A fourth item</li>
<li class="list-group-item">And a fifth one</li>
</ul>
Vipengee vinavyotumika
Ongeza .active
kwa a .list-group-item
ili kuonyesha uteuzi unaotumika sasa.
- Kipengee kinachotumika
- Kipengee cha pili
- Kipengee cha tatu
- Kipengee cha nne
- Na ya tano
<ul class="list-group">
<li class="list-group-item active" aria-current="true">An active item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
<li class="list-group-item">A fourth item</li>
<li class="list-group-item">And a fifth one</li>
</ul>
Vipengee vilivyozimwa
Ongeza .disabled
kwa a .list-group-item
ili kuifanya ionekane kuwa imezimwa. Kumbuka kuwa vipengee vingine vilivyo na .disabled
pia vitahitaji JavaScript maalum ili kuzima kabisa matukio yao ya kubofya (kwa mfano, viungo).
- Kipengee kilichozimwa
- Kipengee cha pili
- Kipengee cha tatu
- Kipengee cha nne
- Na ya tano
<ul class="list-group">
<li class="list-group-item disabled" aria-disabled="true">A disabled item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
<li class="list-group-item">A fourth item</li>
<li class="list-group-item">And a fifth one</li>
</ul>
Viungo na vifungo
Tumia <a>
s au <button>
s kuunda vipengee vya kikundi vinavyoweza kutekelezeka kwa hali ya kuelea, iliyozimwa, na amilifu kwa kuongeza .list-group-item-action
. Tunatenganisha madarasa haya ya uwongo ili kuhakikisha vikundi vya orodha vilivyoundwa na vipengee visivyoingiliana (kama vile <li>
s au <div>
s) havitoi uwezo wa kubofya au kugusa.
Hakikisha hutumii madarasa ya kawaida .btn
hapa .
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action active" aria-current="true">
The current link item
</a>
<a href="#" class="list-group-item list-group-item-action">A second link item</a>
<a href="#" class="list-group-item list-group-item-action">A third link item</a>
<a href="#" class="list-group-item list-group-item-action">A fourth link item</a>
<a class="list-group-item list-group-item-action disabled">A disabled link item</a>
</div>
Na <button>
s, unaweza pia kutumia disabled
sifa badala ya .disabled
darasa. Cha kusikitisha ni kwamba, <a>
s haiungi mkono sifa ya walemavu.
<div class="list-group">
<button type="button" class="list-group-item list-group-item-action active" aria-current="true">
The current button
</button>
<button type="button" class="list-group-item list-group-item-action">A second button item</button>
<button type="button" class="list-group-item list-group-item-action">A third button item</button>
<button type="button" class="list-group-item list-group-item-action">A fourth button item</button>
<button type="button" class="list-group-item list-group-item-action" disabled>A disabled button item</button>
</div>
Suuza
Ongeza .list-group-flush
ili kuondoa baadhi ya mipaka na pembe zilizoviringwa ili kutoa vipengee vya orodha ukingo-kwa-kingo katika kontena kuu (km, kadi).
- Kipengee
- Kipengee cha pili
- Kipengee cha tatu
- Kipengee cha nne
- Na ya tano
<ul class="list-group list-group-flush">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
<li class="list-group-item">A fourth item</li>
<li class="list-group-item">And a fifth one</li>
</ul>
Nambari
Ongeza .list-group-numbered
darasa la kirekebishaji (na kwa hiari tumia <ol>
kipengee) kuchagua vipengee vya kikundi vilivyo na nambari. Nambari hutolewa kupitia CSS (kinyume na mtindo wa <ol>
kivinjari chaguo-msingi) kwa uwekaji bora ndani ya vipengee vya kikundi na kuruhusu ubinafsishaji bora.
Nambari hutolewa na counter-reset
kwenye <ol>
, na kisha kutengenezwa kwa mtindo na kuwekwa na ::before
kipengele cha uwongo kwenye <li>
with counter-increment
na content
.
- Kipengee cha orodha
- Kipengee cha orodha
- Kipengee cha orodha
<ol class="list-group list-group-numbered">
<li class="list-group-item">A list item</li>
<li class="list-group-item">A list item</li>
<li class="list-group-item">A list item</li>
</ol>
Hizi hufanya kazi vizuri na yaliyomo maalum pia.
-
Kichwa kidogoMaudhui ya kipengee cha orodha
-
Kichwa kidogoMaudhui ya kipengee cha orodha
-
Kichwa kidogoMaudhui ya kipengee cha orodha
<ol class="list-group list-group-numbered">
<li class="list-group-item d-flex justify-content-between align-items-start">
<div class="ms-2 me-auto">
<div class="fw-bold">Subheading</div>
Content for list item
</div>
<span class="badge bg-primary rounded-pill">14</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-start">
<div class="ms-2 me-auto">
<div class="fw-bold">Subheading</div>
Content for list item
</div>
<span class="badge bg-primary rounded-pill">14</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-start">
<div class="ms-2 me-auto">
<div class="fw-bold">Subheading</div>
Content for list item
</div>
<span class="badge bg-primary rounded-pill">14</span>
</li>
</ol>
Mlalo
Ongeza .list-group-horizontal
ili kubadilisha mpangilio wa orodha ya vipengee vya kikundi kutoka wima hadi mlalo katika sehemu zote za kukatisha. Vinginevyo, chagua lahaja jibu .list-group-horizontal-{sm|md|lg|xl|xxl}
ili kufanya kikundi cha orodha kiwe mlalo kuanzia kwenye sehemu hiyo ya kuvunja min-width
. Kwa sasa vikundi vya orodha za mlalo haviwezi kuunganishwa na vikundi vya orodha ya safisha.
ProTip: Je, unataka vipengee vya kikundi vya upana wa usawa vikiwa mlalo? Ongeza .flex-fill
kwa kila kipengee cha kikundi cha orodha.
- Kipengee
- Kipengee cha pili
- Kipengee cha tatu
- Kipengee
- Kipengee cha pili
- Kipengee cha tatu
- Kipengee
- Kipengee cha pili
- Kipengee cha tatu
- Kipengee
- Kipengee cha pili
- Kipengee cha tatu
- Kipengee
- Kipengee cha pili
- Kipengee cha tatu
- Kipengee
- Kipengee cha pili
- Kipengee cha tatu
<ul class="list-group list-group-horizontal">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
<ul class="list-group list-group-horizontal-sm">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
<ul class="list-group list-group-horizontal-md">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
<ul class="list-group list-group-horizontal-lg">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
<ul class="list-group list-group-horizontal-xl">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
<ul class="list-group list-group-horizontal-xxl">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
Madarasa ya muktadha
Tumia madarasa ya muktadha ili kuunda vipengee vya orodha vilivyo na usuli na rangi maridadi.
- Kipengee rahisi cha orodha chaguo-msingi cha kikundi
- Kipengee rahisi cha orodha ya msingi
- Kipengee rahisi cha kikundi cha sekondari
- Kipengee rahisi cha orodha ya mafanikio
- Kipengee rahisi cha orodha ya hatari
- Kipengee rahisi cha orodha ya onyo
- Kipengee rahisi cha orodha ya habari
- Kipengee rahisi cha orodha ya mwanga
- Kipengee rahisi cha kikundi cha orodha nyeusi
<ul class="list-group">
<li class="list-group-item">A simple default list group item</li>
<li class="list-group-item list-group-item-primary">A simple primary list group item</li>
<li class="list-group-item list-group-item-secondary">A simple secondary list group item</li>
<li class="list-group-item list-group-item-success">A simple success list group item</li>
<li class="list-group-item list-group-item-danger">A simple danger list group item</li>
<li class="list-group-item list-group-item-warning">A simple warning list group item</li>
<li class="list-group-item list-group-item-info">A simple info list group item</li>
<li class="list-group-item list-group-item-light">A simple light list group item</li>
<li class="list-group-item list-group-item-dark">A simple dark list group item</li>
</ul>
Madarasa ya muktadha pia hufanya kazi na .list-group-item-action
. Kumbuka nyongeza ya mitindo ya kuelea hapa haipo katika mfano uliopita. Pia inaungwa mkono ni .active
serikali; itumie ili kuonyesha uteuzi unaotumika kwenye kipengee cha kikundi cha muktadha.
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action">A simple default list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-primary">A simple primary list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-secondary">A simple secondary list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-success">A simple success list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-danger">A simple danger list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-warning">A simple warning list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-info">A simple info list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-light">A simple light list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-dark">A simple dark list group item</a>
</div>
Kuwasilisha maana kwa teknolojia za usaidizi
Kutumia rangi ili kuongeza maana hutoa tu kielelezo cha kuona, ambacho hakitawasilishwa kwa watumiaji wa teknolojia saidizi - kama vile visoma skrini. Hakikisha kwamba maelezo yanayoashiriwa na rangi ni dhahiri kutoka kwa maudhui yenyewe (km maandishi yanayoonekana), au yanajumuishwa kupitia njia mbadala, kama vile maandishi ya ziada yaliyofichwa na .visually-hidden
darasa.
Na beji
Ongeza beji kwa bidhaa yoyote ya kikundi ili kuonyesha hesabu ambazo hazijasomwa, shughuli na zaidi kwa usaidizi wa baadhi ya huduma .
- Kipengee cha orodha14
- Kipengee cha orodha ya pili2
- Kipengee cha orodha ya tatu1
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center">
A list item
<span class="badge bg-primary rounded-pill">14</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
A second list item
<span class="badge bg-primary rounded-pill">2</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
A third list item
<span class="badge bg-primary rounded-pill">1</span>
</li>
</ul>
Maudhui maalum
Ongeza karibu HTML yoyote ndani, hata kwa vikundi vya orodha vilivyounganishwa kama ilivyo hapa chini, kwa usaidizi wa huduma za flexbox .
Orodhesha kichwa cha kipengee cha kikundi
siku 3 zilizopitaBaadhi ya maudhui ya kishika nafasi katika aya.
Na maandishi madogo.Orodhesha kichwa cha kipengee cha kikundi
siku 3 zilizopitaBaadhi ya maudhui ya kishika nafasi katika aya.
Na baadhi ya maandishi madogo yamenyamazishwa.Orodhesha kichwa cha kipengee cha kikundi
siku 3 zilizopitaBaadhi ya maudhui ya kishika nafasi katika aya.
Na baadhi ya maandishi madogo yamenyamazishwa.<div class="list-group">
<a href="#" class="list-group-item list-group-item-action active" aria-current="true">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">List group item heading</h5>
<small>3 days ago</small>
</div>
<p class="mb-1">Some placeholder content in a paragraph.</p>
<small>And some small print.</small>
</a>
<a href="#" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">List group item heading</h5>
<small class="text-muted">3 days ago</small>
</div>
<p class="mb-1">Some placeholder content in a paragraph.</p>
<small class="text-muted">And some muted small print.</small>
</a>
<a href="#" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">List group item heading</h5>
<small class="text-muted">3 days ago</small>
</div>
<p class="mb-1">Some placeholder content in a paragraph.</p>
<small class="text-muted">And some muted small print.</small>
</a>
</div>
Visanduku vya kuteua na redio
Weka visanduku vya kuteua vya Bootstrap na redio ndani ya orodha ya vipengee vya kikundi na ubadilishe kukufaa inavyohitajika. Unaweza kuzitumia bila <label>
s, lakini tafadhali kumbuka kujumuisha aria-label
sifa na thamani ya ufikivu.
<ul class="list-group">
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="firstCheckbox">
<label class="form-check-label" for="firstCheckbox">First checkbox</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="secondCheckbox">
<label class="form-check-label" for="secondCheckbox">Second checkbox</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="thirdCheckbox">
<label class="form-check-label" for="thirdCheckbox">Third checkbox</label>
</li>
</ul>
<ul class="list-group">
<li class="list-group-item">
<input class="form-check-input me-1" type="radio" name="listGroupRadio" value="" id="firstRadio" checked>
<label class="form-check-label" for="firstRadio">First radio</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="radio" name="listGroupRadio" value="" id="secondRadio">
<label class="form-check-label" for="secondRadio">Second radio</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="radio" name="listGroupRadio" value="" id="thirdRadio">
<label class="form-check-label" for="thirdRadio">Third radio</label>
</li>
</ul>
Unaweza kutumia .stretched-link
kwenye <label>
s kufanya kipengee chote cha kikundi cha orodha kubofya.
<ul class="list-group">
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="firstCheckboxStretched">
<label class="form-check-label stretched-link" for="firstCheckboxStretched">First checkbox</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="secondCheckboxStretched">
<label class="form-check-label stretched-link" for="secondCheckboxStretched">Second checkbox</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="thirdCheckboxStretched">
<label class="form-check-label stretched-link" for="thirdCheckboxStretched">Third checkbox</label>
</li>
</ul>
CSS
Vigezo
Imeongezwa katika v5.2.0Kama sehemu ya mbinu ya mabadiliko ya vigezo vya CSS ya Bootstrap, vikundi vya orodha sasa vinatumia viambatisho vya ndani vya CSS .list-group
kwa uboreshaji wa wakati halisi. Thamani za anuwai za CSS zimewekwa kupitia Sass, kwa hivyo ubinafsishaji wa Sass bado unatumika, pia.
--#{$prefix}list-group-color: #{$list-group-color};
--#{$prefix}list-group-bg: #{$list-group-bg};
--#{$prefix}list-group-border-color: #{$list-group-border-color};
--#{$prefix}list-group-border-width: #{$list-group-border-width};
--#{$prefix}list-group-border-radius: #{$list-group-border-radius};
--#{$prefix}list-group-item-padding-x: #{$list-group-item-padding-x};
--#{$prefix}list-group-item-padding-y: #{$list-group-item-padding-y};
--#{$prefix}list-group-action-color: #{$list-group-action-color};
--#{$prefix}list-group-action-hover-color: #{$list-group-action-hover-color};
--#{$prefix}list-group-action-hover-bg: #{$list-group-hover-bg};
--#{$prefix}list-group-action-active-color: #{$list-group-action-active-color};
--#{$prefix}list-group-action-active-bg: #{$list-group-action-active-bg};
--#{$prefix}list-group-disabled-color: #{$list-group-disabled-color};
--#{$prefix}list-group-disabled-bg: #{$list-group-disabled-bg};
--#{$prefix}list-group-active-color: #{$list-group-active-color};
--#{$prefix}list-group-active-bg: #{$list-group-active-bg};
--#{$prefix}list-group-active-border-color: #{$list-group-active-border-color};
Vigezo vya Sass
$list-group-color: $gray-900;
$list-group-bg: $white;
$list-group-border-color: rgba($black, .125);
$list-group-border-width: $border-width;
$list-group-border-radius: $border-radius;
$list-group-item-padding-y: $spacer * .5;
$list-group-item-padding-x: $spacer;
$list-group-item-bg-scale: -80%;
$list-group-item-color-scale: 40%;
$list-group-hover-bg: $gray-100;
$list-group-active-color: $component-active-color;
$list-group-active-bg: $component-active-bg;
$list-group-active-border-color: $list-group-active-bg;
$list-group-disabled-color: $gray-600;
$list-group-disabled-bg: $list-group-bg;
$list-group-action-color: $gray-700;
$list-group-action-hover-color: $list-group-action-color;
$list-group-action-active-color: $body-color;
$list-group-action-active-bg: $gray-200;
Mchanganyiko
Inatumika pamoja na $theme-colors
kutengeneza lahaja za muktadha za .list-group-item
s.
@mixin list-group-item-variant($state, $background, $color) {
.list-group-item-#{$state} {
color: $color;
background-color: $background;
&.list-group-item-action {
&:hover,
&:focus {
color: $color;
background-color: shade-color($background, 10%);
}
&.active {
color: $white;
background-color: $color;
border-color: $color;
}
}
}
}
Kitanzi
Kitanzi ambacho hutoa madarasa ya kurekebisha na list-group-item-variant()
mchanganyiko.
// List group contextual variants
//
// Add modifier classes to change text and background color on individual items.
// Organizationally, this must come after the `:hover` states.
@each $state, $value in $theme-colors {
$list-group-variant-bg: shift-color($value, $list-group-item-bg-scale);
$list-group-variant-color: shift-color($value, $list-group-item-color-scale);
@if (contrast-ratio($list-group-variant-bg, $list-group-variant-color) < $min-contrast-ratio) {
$list-group-variant-color: mix($value, color-contrast($list-group-variant-bg), abs($list-group-item-color-scale));
}
@include list-group-item-variant($state, $list-group-variant-bg, $list-group-variant-color);
}
Tabia ya JavaScript
Tumia kichupo cha programu-jalizi ya JavaScript—ijumuishe kibinafsi au kupitia faili iliyokusanywa bootstrap.js
—ili kupanua kikundi chetu cha orodha ili kuunda vidirisha vya kichupo vya maudhui ya ndani.
<div class="row">
<div class="col-4">
<div class="list-group" id="list-tab" role="tablist">
<a class="list-group-item list-group-item-action active" id="list-home-list" data-bs-toggle="list" href="#list-home" role="tab" aria-controls="list-home">Home</a>
<a class="list-group-item list-group-item-action" id="list-profile-list" data-bs-toggle="list" href="#list-profile" role="tab" aria-controls="list-profile">Profile</a>
<a class="list-group-item list-group-item-action" id="list-messages-list" data-bs-toggle="list" href="#list-messages" role="tab" aria-controls="list-messages">Messages</a>
<a class="list-group-item list-group-item-action" id="list-settings-list" data-bs-toggle="list" href="#list-settings" role="tab" aria-controls="list-settings">Settings</a>
</div>
</div>
<div class="col-8">
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="list-home" role="tabpanel" aria-labelledby="list-home-list">...</div>
<div class="tab-pane fade" id="list-profile" role="tabpanel" aria-labelledby="list-profile-list">...</div>
<div class="tab-pane fade" id="list-messages" role="tabpanel" aria-labelledby="list-messages-list">...</div>
<div class="tab-pane fade" id="list-settings" role="tabpanel" aria-labelledby="list-settings-list">...</div>
</div>
</div>
</div>
Kutumia sifa za data
Unaweza kuwezesha urambazaji wa kikundi cha orodha bila kuandika JavaScript yoyote kwa kubainisha tu data-bs-toggle="list"
au kwa kipengele. Tumia sifa hizi za data kwenye .list-group-item
.
<div role="tabpanel">
<!-- List group -->
<div class="list-group" id="myList" role="tablist">
<a class="list-group-item list-group-item-action active" data-bs-toggle="list" href="#home" role="tab">Home</a>
<a class="list-group-item list-group-item-action" data-bs-toggle="list" href="#profile" role="tab">Profile</a>
<a class="list-group-item list-group-item-action" data-bs-toggle="list" href="#messages" role="tab">Messages</a>
<a class="list-group-item list-group-item-action" data-bs-toggle="list" href="#settings" role="tab">Settings</a>
</div>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="home" role="tabpanel">...</div>
<div class="tab-pane" id="profile" role="tabpanel">...</div>
<div class="tab-pane" id="messages" role="tabpanel">...</div>
<div class="tab-pane" id="settings" role="tabpanel">...</div>
</div>
</div>
Kupitia JavaScript
Washa kipengee cha orodha kinachoweza kutekelezeka kupitia JavaScript (kila kipengee cha orodha kinahitaji kuamilishwa kibinafsi):
const triggerTabList = document.querySelectorAll('#myTab a')
triggerTabList.forEach(triggerEl => {
const tabTrigger = new bootstrap.Tab(triggerEl)
triggerEl.addEventListener('click', event => {
event.preventDefault()
tabTrigger.show()
})
})
Unaweza kuwezesha kipengee cha orodha kwa njia kadhaa:
const triggerEl = document.querySelector('#myTab a[href="#profile"]')
bootstrap.Tab.getInstance(triggerEl).show() // Select tab by name
const triggerFirstTabEl = document.querySelector('#myTab li:first-child a')
bootstrap.Tab.getInstance(triggerFirstTabEl).show() // Select first tab
Fifisha athari
Ili kufanya kidirisha cha vichupo kufifia, ongeza .fade
kwa kila .tab-pane
. Kidirisha cha kichupo cha kwanza lazima pia kiwe na .show
maudhui ya awali kuonekana.
<div class="tab-content">
<div class="tab-pane fade show active" id="home" role="tabpanel">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel">...</div>
<div class="tab-pane fade" id="messages" role="tabpanel">...</div>
<div class="tab-pane fade" id="settings" role="tabpanel">...</div>
</div>
Mbinu
Njia za Asynchronous na mabadiliko
Njia zote za API ni za asynchronous na zinaanzisha mpito . Wanarudi kwa mpigaji mara tu mpito unapoanza lakini kabla haujaisha . Kwa kuongeza, simu ya mbinu kwenye sehemu ya mpito itapuuzwa .
Huwasha maudhui yako kama kipengele cha kichupo.
Unaweza kuunda mfano wa tabo na mjenzi, kwa mfano:
const bsTab = new bootstrap.Tab('#myTab')
Njia | Maelezo |
---|---|
dispose |
Huharibu kichupo cha kipengele. |
getInstance |
Njia tuli ambayo hukuruhusu kupata mfano wa tabo inayohusishwa na kipengee cha DOM, unaweza kuitumia kama hii: bootstrap.Tab.getInstance(element) . |
getOrCreateInstance |
Mbinu tuli ambayo inarejesha mfano wa kichupo kinachohusishwa na kipengele cha DOM au kuunda kipya iwapo hakijaanzishwa. Unaweza kuitumia kama hii bootstrap.Tab.getOrCreateInstance(element) :. |
show |
Huchagua kichupo kilichotolewa na kuonyesha kidirisha chake kinachohusiana. Kichupo kingine chochote ambacho kilichaguliwa hapo awali kitaacha kuchaguliwa na kidirisha chake kinachohusishwa hufichwa. Hurejesha kwa mpigaji kabla kidirisha cha kichupo hakijaonyeshwa (yaani kabla ya shown.bs.tab tukio kutokea). |
Matukio
Wakati wa kuonyesha kichupo kipya, matukio huwaka kwa mpangilio ufuatao:
hide.bs.tab
(kwenye kichupo kinachotumika sasa)show.bs.tab
(kwenye kichupo cha-kuonyeshwa)hidden.bs.tab
(kwenye kichupo amilifu kilichotangulia, sawa na chahide.bs.tab
tukio)shown.bs.tab
(kwenye kichupo kipya-kilichoonyeshwa, sawa na chashow.bs.tab
tukio)
Ikiwa hakuna kichupo kilichokuwa tayari kinatumika, basi matukio hide.bs.tab
na hidden.bs.tab
matukio hayatafutwa.
Aina ya tukio | Maelezo |
---|---|
hide.bs.tab |
Tukio hili huwaka wakati kichupo kipya kitaonyeshwa (na kwa hivyo kichupo amilifu cha awali kitafichwa). Tumia event.target na event.relatedTarget kulenga kichupo kinachotumika sasa na kichupo kipya kitakachotumika hivi karibuni, mtawalia. |
hidden.bs.tab |
Tukio hili huwaka baada ya kichupo kipya kuonyeshwa (na kwa hivyo kichupo amilifu cha awali kimefichwa). Tumia event.target na event.relatedTarget kulenga kichupo amilifu cha awali na kichupo kipya kinachotumika, mtawalia. |
show.bs.tab |
Tukio hili linawaka kwenye onyesho la kichupo, lakini kabla ya kichupo kipya kuonyeshwa. Tumia event.target na event.relatedTarget kulenga kichupo amilifu na kichupo amilifu cha awali (kama kinapatikana) mtawalia. |
shown.bs.tab |
Tukio hili huwashwa kwenye onyesho la kichupo baada ya kichupo kuonyeshwa. Tumia event.target na event.relatedTarget kulenga kichupo amilifu na kichupo amilifu cha awali (kama kinapatikana) mtawalia. |
const tabElms = document.querySelectorAll('a[data-bs-toggle="list"]')
tabElms.forEach(tabElm => {
tabElm.addEventListener('shown.bs.tab', event => {
event.target // newly activated tab
event.relatedTarget // previous active tab
})
})