Source

Ilista ti grupo

Dagiti grupo ti listaan ​​ket maysa a nalaka a maibagay ken nabileg a paset para iti panangiparang ti serye ti linaon. Baliwan ken palawaen dagitoy tapno suportaran ti dandani aniaman a linaon iti uneg.

Pangrugian a pagarigan

Ti kangrunaan unay a grupo ti listaan ​​ket ti saan a naurnos a listaan ​​nga addaan kadagiti banag ti listaan ​​ken dagiti umno a klase. Mangbangon iti dayta babaen kadagiti pagpilian a sumaganad, wenno babaen ti bukodmo a CSS no kasapulan.

  • Cras laeng nga odio
  • Dapibus ac pasilidad iti
  • Morbi leo nga risus
  • Porta nga consectetur nga
  • Vestibulum iti eros
<ul class="list-group">
  <li class="list-group-item">Cras justo odio</li>
  <li class="list-group-item">Dapibus ac facilisis in</li>
  <li class="list-group-item">Morbi leo risus</li>
  <li class="list-group-item">Porta ac consectetur ac</li>
  <li class="list-group-item">Vestibulum at eros</li>
</ul>

Aktibo a banag

Inayon .activeiti a .list-group-itemtapno mangipakita ti agdama nga aktibo a panagpili.

  • Cras laeng nga odio
  • Dapibus ac pasilidad iti
  • Morbi leo nga risus
  • Porta nga consectetur nga
  • Vestibulum iti eros
<ul class="list-group">
  <li class="list-group-item active">Cras justo odio</li>
  <li class="list-group-item">Dapibus ac facilisis in</li>
  <li class="list-group-item">Morbi leo risus</li>
  <li class="list-group-item">Porta ac consectetur ac</li>
  <li class="list-group-item">Vestibulum at eros</li>
</ul>

Dagiti baldado a banag

Inayon .disablediti a .list-group-itemtapno agparang a baldado. Imutektekanyo a dagiti sumagmamano nga elemento nga addaan .disabledket kasapulan pay ti kostumbre a JavaScript tapno naan-anay a mangbaldado kadagiti pasamak ti panagpidutda (kas pagarigan, dagiti silpo).

  • Cras laeng nga odio
  • Dapibus ac pasilidad iti
  • Morbi leo nga risus
  • Porta nga consectetur nga
  • Vestibulum iti eros
<ul class="list-group">
  <li class="list-group-item disabled" aria-disabled="true">Cras justo odio</li>
  <li class="list-group-item">Dapibus ac facilisis in</li>
  <li class="list-group-item">Morbi leo risus</li>
  <li class="list-group-item">Porta ac consectetur ac</li>
  <li class="list-group-item">Vestibulum at eros</li>
</ul>

Usaren <a>ti s wenno <button>s tapno mangpartuat kadagiti maaramid a banag ti grupo ti listaan ​​nga addaan kadagiti hover, baldado, ken aktibo nga estado babaen ti pananginayon ti .list-group-item-action. Pagsisinaenmi dagitoy a pseudo-klase tapno masigurado a dagiti grupo ti listaan ​​a naaramid kadagiti saan nga interaktibo nga elemento (kas <li>ti s wenno <div>s) ket saan a mangipaay ti panagpidut wenno panag-tap affordance.

Siguraduen a saan nga usaren dagiti gagangay a .btnklase ditoy .

<div class="list-group">
  <a href="#" class="list-group-item list-group-item-action active">
    Cras justo odio
  </a>
  <a href="#" class="list-group-item list-group-item-action">Dapibus ac facilisis in</a>
  <a href="#" class="list-group-item list-group-item-action">Morbi leo risus</a>
  <a href="#" class="list-group-item list-group-item-action">Porta ac consectetur ac</a>
  <a href="#" class="list-group-item list-group-item-action disabled" tabindex="-1" aria-disabled="true">Vestibulum at eros</a>
</div>

Babaen <button>ti s, mabalinmo pay nga usaren ti disabledattribute imbes a ti .disabledklase. Nakalkaldaang, <a>saan a suportaran dagiti s ti baldado nga attribute.

<div class="list-group">
  <button type="button" class="list-group-item list-group-item-action active">
    Cras justo odio
  </button>
  <button type="button" class="list-group-item list-group-item-action">Dapibus ac facilisis in</button>
  <button type="button" class="list-group-item list-group-item-action">Morbi leo risus</button>
  <button type="button" class="list-group-item list-group-item-action">Porta ac consectetur ac</button>
  <button type="button" class="list-group-item list-group-item-action" disabled>Vestibulum at eros</button>
</div>

Ag-flush

Inayon .list-group-flushtapno maikkat dagiti sumagmamano a beddeng ken dagiti nagtimbukel a suli tapno mangiparang kadagiti banag ti grupo ti listaan ​​iti igid-aginggana-iti-igid iti maysa a nagannak a pagkargaan (kas pagarigan, dagiti kard).

  • Cras laeng nga odio
  • Dapibus ac pasilidad iti
  • Morbi leo nga risus
  • Porta nga consectetur nga
  • Vestibulum iti eros
<ul class="list-group list-group-flush">
  <li class="list-group-item">Cras justo odio</li>
  <li class="list-group-item">Dapibus ac facilisis in</li>
  <li class="list-group-item">Morbi leo risus</li>
  <li class="list-group-item">Porta ac consectetur ac</li>
  <li class="list-group-item">Vestibulum at eros</li>
</ul>

Paidda

Inayon .list-group-horizontaltapno agbaliw ti layout dagiti banag ti grupo ti listaan ​​manipud iti bertikal aginggana iti horisontal iti ballasiw dagiti amin a breakpoint. Saan laeng a dayta, agpili ti sumungbat a variante .list-group-horizontal-{sm|md|lg|xl}tapno mangaramid ti maysa a grupo ti listaan ​​a horisontal a mangrugi iti dayta a breakpoint's min-width. Iti agdama dagiti horisontal a grupo ti listaan ​​ket saan a mabalin a maitipon kadagiti grupo ti listaan ​​ti flush.

ProTip: Kayatmo dagiti agpapada ti kalawana a banag ti grupo ti listaan ​​no horizontal? Inayon .flex-filliti tunggal banag ti grupo ti listaan.

  • Cras laeng nga odio
  • Dapibus ac pasilidad iti
  • Morbi leo nga risus
<ul class="list-group list-group-horizontal">
  <li class="list-group-item">Cras justo odio</li>
  <li class="list-group-item">Dapibus ac facilisis in</li>
  <li class="list-group-item">Morbi leo risus</li>
</ul>
  • Cras laeng nga odio
  • Dapibus ac pasilidad iti
  • Morbi leo nga risus
<ul class="list-group list-group-horizontal-sm">
  <li class="list-group-item">Cras justo odio</li>
  <li class="list-group-item">Dapibus ac facilisis in</li>
  <li class="list-group-item">Morbi leo risus</li>
</ul>
  • Cras laeng nga odio
  • Dapibus ac pasilidad iti
  • Morbi leo nga risus
<ul class="list-group list-group-horizontal-md">
  <li class="list-group-item">Cras justo odio</li>
  <li class="list-group-item">Dapibus ac facilisis in</li>
  <li class="list-group-item">Morbi leo risus</li>
</ul>
  • Cras laeng nga odio
  • Dapibus ac pasilidad iti
  • Morbi leo nga risus
<ul class="list-group list-group-horizontal-lg">
  <li class="list-group-item">Cras justo odio</li>
  <li class="list-group-item">Dapibus ac facilisis in</li>
  <li class="list-group-item">Morbi leo risus</li>
</ul>
  • Cras laeng nga odio
  • Dapibus ac pasilidad iti
  • Morbi leo nga risus
<ul class="list-group list-group-horizontal-xl">
  <li class="list-group-item">Cras justo odio</li>
  <li class="list-group-item">Dapibus ac facilisis in</li>
  <li class="list-group-item">Morbi leo risus</li>
</ul>

Dagiti klase ti konteksto

Usaren dagiti klase ti konteksto tapno estilo ilista dagiti banag nga addaan iti estado a likudan ken kolor.

  • Dapibus ac pasilidad iti
  • Maysa a simple a banag ti grupo ti kangrunaan a listaan
  • Maysa a simple a segundario a listaan ​​a banag ti grupo
  • Maysa a simple a banag ti grupo ti listaan ​​ti balligi
  • Maysa a simple a banag ti grupo ti listaan ​​ti peggad
  • Maysa a simple a pakdaar a listaan ​​a banag ti grupo
  • Maysa a simple nga info list group item
  • Maysa a simple a banag ti grupo ti listaan ​​ti lawag
  • Maysa a simple a nasipnget a listaan ​​a banag ti grupo
<ul class="list-group">
  <li class="list-group-item">Dapibus ac facilisis in</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>

Dagiti klase ti konteksto ket agtrabaho met iti .list-group-item-action. Panunoten ti pannakainayon dagiti estilo ti hover ditoy a saan nga adda iti napalabas a pagarigan. Suportaran pay ti .activeestado; iyaplikar daytoy tapno mangipakita ti aktibo a panagpili iti maysa a banag ti grupo ti listaan ​​ti konteksto.

<div class="list-group">
  <a href="#" class="list-group-item list-group-item-action">Dapibus ac facilisis in</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>
Panangipaay ti kaipapanan kadagiti makatulong a teknolohia

Ti panagusar ti kolor tapno mangnayon ti kaipapanan ket mangipaay laeng ti makita a pakakitaan, a saan a maidanon kadagiti agar-aramat kadagiti makatulong a teknolohia – kas dagiti screen reader. Siguraduen a ti impormasion a naipasimudaag babaen ti kolor ket nalawag manipud iti linaon a mismo (kas pagarigan ti makita a teksto), wenno mairaman babaen dagiti alternatibo a wagas, a kas ti kanayonan a teksto a nailemmeng a kadua ti .sr-onlyklase.

Adda badge-na

Manginayon kadagiti badge iti ania man a banag ti grupo ti listaan ​​tapno maipakita dagiti saan a nabasa a bilang, aktibidad, ken dadduma pay babaen ti tulong ti sumagmamano a utilidad .

  • Cras laeng nga odio14 nga
  • Dapibus ac pasilidad iti2. 2
  • Morbi leo nga risus1 nga
<ul class="list-group">
  <li class="list-group-item d-flex justify-content-between align-items-center">
    Cras justo odio
    <span class="badge badge-primary badge-pill">14</span>
  </li>
  <li class="list-group-item d-flex justify-content-between align-items-center">
    Dapibus ac facilisis in
    <span class="badge badge-primary badge-pill">2</span>
  </li>
  <li class="list-group-item d-flex justify-content-between align-items-center">
    Morbi leo risus
    <span class="badge badge-primary badge-pill">1</span>
  </li>
</ul>

Kostumbre a linaon

Inayon ti gangani nga ania man nga HTML iti uneg, urayno para kadagiti naisilpo a grupo ti listaan ​​a kas ti maysa iti baba, babaen ti tulong dagiti flexbox a utilidad .

<div class="list-group">
  <a href="#" class="list-group-item list-group-item-action active">
    <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">Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</p>
    <small>Donec id elit non mi porta.</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">Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</p>
    <small class="text-muted">Donec id elit non mi porta.</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">Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.</p>
    <small class="text-muted">Donec id elit non mi porta.</small>
  </a>
</div>

Kababalin ti JavaScript

Usaren ti tab a plugin ti JavaScript—iraman daytoy a saggaysa wenno babaen ti naurnong bootstrap.jsa file—tapno mangpalawa ti grupomi iti listaan ​​tapno mangpartuat kadagiti tabbable a pane ti lokal a linaon.

<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-toggle="list" href="#list-home" role="tab" aria-controls="home">Home</a>
      <a class="list-group-item list-group-item-action" id="list-profile-list" data-toggle="list" href="#list-profile" role="tab" aria-controls="profile">Profile</a>
      <a class="list-group-item list-group-item-action" id="list-messages-list" data-toggle="list" href="#list-messages" role="tab" aria-controls="messages">Messages</a>
      <a class="list-group-item list-group-item-action" id="list-settings-list" data-toggle="list" href="#list-settings" role="tab" aria-controls="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>

Panangusar kadagiti attribute ti datos

Mabalinmo nga aktiboen ti nabigasion ti grupo ti listaan ​​a saan a mangisurat ti ania man a JavaScript babaen ti basta panangidatag data-toggle="list"wenno iti maysa nga elemento. Usaren dagitoy a kababalin ti datos iti .list-group-item.

<!-- List group -->
<div class="list-group" id="myList" role="tablist">
  <a class="list-group-item list-group-item-action active" data-toggle="list" href="#home" role="tab">Home</a>
  <a class="list-group-item list-group-item-action" data-toggle="list" href="#profile" role="tab">Profile</a>
  <a class="list-group-item list-group-item-action" data-toggle="list" href="#messages" role="tab">Messages</a>
  <a class="list-group-item list-group-item-action" data-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>

Babaen ti JavaScript

Pagbalinen a banag ti listaan ​​ti tabbable babaen ti JavaScript (tunggal banag ti listaan ​​ket kasapulan a mapaaktibo a saggaysa):

$('#myList a').on('click', function (e) {
  e.preventDefault()
  $(this).tab('show')
})

Mabalinmo nga aktiboen ti indibidual a banag ti listaan ​​iti sumagmamano a wagas:

$('#myList a[href="#profile"]').tab('show') // Select tab by name
$('#myList a:first-child').tab('show') // Select first tab
$('#myList a:last-child').tab('show') // Select last tab
$('#myList a:nth-child(3)').tab('show') // Select third tab

Fade nga epekto

Tapno agkupas ti tabs panel, inayon .fadeiti tunggal .tab-pane. Ti umuna a tab pane ket masapul pay .showa mangaramid ti umuna a linaon a makita.

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

Dagiti Pamay-an

$().tab nga

Paaktiboenna ti elemento ti banag ti listaan ​​ken pagkargaan ti linaon. Ti tab ket rumbeng nga addaan iti maysa data-targetwenno maysa a hrefmangpuntiria iti maysa a container node iti DOM.

<div class="list-group" id="myList" role="tablist">
  <a class="list-group-item list-group-item-action active" data-toggle="list" href="#home" role="tab">Home</a>
  <a class="list-group-item list-group-item-action" data-toggle="list" href="#profile" role="tab">Profile</a>
  <a class="list-group-item list-group-item-action" data-toggle="list" href="#messages" role="tab">Messages</a>
  <a class="list-group-item list-group-item-action" data-toggle="list" href="#settings" role="tab">Settings</a>
</div>

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

<script>
  $(function () {
    $('#myList a:last-child').tab('show')
  })
</script>

.tab ('ipakita') .

Selects the given list item and shows its associated pane. Any other list item that was previously selected becomes unselected and its associated pane is hidden. Returns to the caller before the tab pane has actually been shown (for example, before the shown.bs.tab event occurs).

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

Events

When showing a new tab, the events fire in the following order:

  1. hide.bs.tab (on the current active tab)
  2. show.bs.tab (on the to-be-shown tab)
  3. hidden.bs.tab (on the previous active tab, the same one as for the hide.bs.tab event)
  4. shown.bs.tab (on the newly-active just-shown tab, the same one as for the show.bs.tab event)

If no tab was already active, the hide.bs.tab and hidden.bs.tab events will not be fired.

Event type Description
show.bs.tab This event fires on tab show, but before the new tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
shown.bs.tab This event fires on tab show after a tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively.
hide.bs.tab This event fires when a new tab is to be shown (and thus the previous active tab is to be hidden). Use event.target and event.relatedTarget to target the current active tab and the new soon-to-be-active tab, respectively.
hidden.bs.tab This event fires after a new tab is shown (and thus the previous active tab is hidden). Use event.target and event.relatedTarget to target the previous active tab and the new active tab, respectively.
$('a[data-toggle="list"]').on('shown.bs.tab', function (e) {
  e.target // newly activated tab
  e.relatedTarget // previous active tab
})