Source

Rōpū rārangi

Ko nga roopu rarangi he waahanga ngawari me te kaha mo te whakaatu i nga raupapa ihirangi. Whakarerekē me te whakawhānui atu ki te tautoko i nga mea katoa o roto.

Tauira taketake

Ko te röpü rärangi mätämua he rärangi rärangi kore me ngä rärangi rärangi me ngä karaehe tika. Hangaia ki runga me nga whiringa ka whai ake, me to ake CSS ranei ina hiahiatia.

  • Kore noa odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum me te 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>

Tūemi hohe

Tāpirihia .activeki a .list-group-itemhei tohu i te tīpakonga hohe onāianei.

  • Kore noa odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum me te 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>

Ko nga mea kua monokia

Taapirihia .disabledki .list-group-itema kia ahua monokia. Kia mahara ko etahi o nga huānga me .disabledte hiahia hoki ki te JavaScript ritenga ki te whakakore i a raatau kaupapa paato (hei tauira, hononga).

  • Kore noa odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum me te eros
<ul class="list-group">
  <li class="list-group-item disabled">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>

Whakamahia <a>te s, s ranei <button>ki te hanga i nga tuemi roopu rarangi mahi me te whakaparo, te mono, me nga ahuatanga hohe ma te taapiri .list-group-item-action. Ka wehea e matou enei karaehe pseudo ki te whakarite kia kore nga roopu rarangi i hangaia mai i nga huānga tauwhitiwhiti-kore (penei <li>i te s, <div>s ranei) e kore e hoatu he paato, he paato ranei te utu.

Kia mahara kia kaua e whakamahia nga .btnkaraehe paerewa i konei .

<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">Vestibulum at eros</a>
</div>

Ki <button>te s, ka taea hoki e koe te whakamahi i te disabledhuanga hei utu mo te .disabledakomanga. Ko te mea pouri, <a>karekau e tautoko i te huanga haua.

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

Horoi

Taapirihia .list-group-flushhei tango i etahi taitapa me nga kokonga porotaka hei whakaatu i nga taonga a te roopu roopu i te taha-ki-te-taha i roto i te ipu matua (hei tauira, nga kaari).

  • Kore noa odio
  • Dapibus ac facilisis in
  • Morbi leo risus
  • Porta ac consectetur ac
  • Vestibulum me te 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>

Nga karaehe horopaki

Whakamahia nga karaehe horopaki ki te whakaahua i nga mea rarangi ingoa me te papamuri me te tae.

  • Dapibus ac facilisis in
  • He tuemi rarangi tuatahi ngawari
  • He tuemi rarangi tuarua ngawari
  • He tuemi rarangi angitu ngawari
  • He tuemi rarangi morearea ngawari
  • He tuemi rarangi whakatupato ngawari
  • He rarangi rarangi korero ngawari
  • He rarangi rarangi marama marama
  • He tuemi rarangi pouri ngawari
<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>

Ka mahi tahi nga karaehe horopaki .list-group-item-action. Tuhia te taapiri o nga momo whakaparo i konei karekau i te tauira o mua. Ka tautokohia ano te .activekawanatanga; whakamahia hei tohu i te kowhiringa hohe i runga i tetahi rarangi rarangi take.

<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>
Te kawe i te tikanga ki nga hangarau awhina

Ko te whakamahi i te tae ki te taapiri i te tikanga he tohu tirohanga noa iho, kaore e tukuna ki nga kaiwhakamahi hangarau awhina - penei i nga kaipanui mata. Me mohio kei te kitea nga korero e tohuhia ana e te tae mai i te ihirangi ake (hei tauira, te tuhinga ka kitea), ka whakaurua ranei ma etahi atu huarahi, penei i etahi atu tuhinga huna ki te .sr-onlyakomanga.

Me nga tohu

Taapirihia nga tohu ki tetahi tuemi roopu rarangi hei whakaatu i nga kaute kaore ano kia panuitia, mahi, me etahi atu ma te awhina o etahi taputapu .

  • Kore noa odio14
  • Dapibus ac facilisis in2
  • Morbi leo risus1
<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>

Ihirangi ritenga

Taapirihia tata ki tetahi HTML kei roto, ahakoa mo nga roopu rarangi hono penei i raro nei, me te awhina o nga taputapu flexbox .

<div class="list-group">
  <a href="#" class="list-group-item list-group-item-action flex-column align-items-start 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 flex-column align-items-start">
    <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 flex-column align-items-start">
    <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>

Te whanonga JavaScript

Whakamahia te ripa JavaScript mono—whakauruhia takitahi, na roto ranei i te bootstrap.jskonae kua whakahiato—ki te whakawhānui i ta matou roopu rarangi ki te hanga i nga panui ripanga o nga ihirangi rohe.

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

Te whakamahi i nga huanga raraunga

Ka taea e koe te whakahohe i te whakatere roopu rarangi me te kore tuhi i tetahi JavaScript ma te tohu noa data-toggle="list", ki runga ranei i tetahi huānga. Whakamahia enei huanga raraunga ki runga .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>

Ma te JavaScript

Whakahohehia te tuemi rarangi ripa ma te JavaScript (me whakahohe takitahi ia rarangi tuemi):

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

Ka taea e koe te whakahohe i nga mea rarangi takitahi i roto i nga huarahi maha:

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

Painga muhani

Kia memeha haere te panui ripa, taapirihia .fadeki ia .tab-pane. Ko te pihanga ripa tuatahi me .showwhakaatu te ihirangi tuatahi.

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

Nga tikanga

$(). ripa

Whakahohe ai i te huānga tūemi rārangi me te ipu ihirangi. Me whai Ripa he data-target, he hrefkohanga ipu ranei kei roto i te 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('whakaatu')

Ka tīpakohia te tūemi rārangi ka whakaatu i tōna pihanga whai pānga. Ko etahi atu tuemi rarangi i tohua i mua ka kore i tohua, ka hunahia tona pihanga hono. Ka hoki ki te kaiwaea i mua i te whakaaturanga o te pihanga ripa (hei tauira, i mua i te shown.bs.tabputa o te takahanga).

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

Nga huihuinga

Ina whakaatu ana i te ripa hou, ka pupuhi nga takahanga i roto i te raupapa e whai ake nei:

  1. hide.bs.tab(i runga i te ripa hohe onāianei)
  2. show.bs.tab(i runga i te ripa hei whakaatu)
  3. hidden.bs.tab(i runga i te ripa hohe o mua, he rite ki te hide.bs.tabkaupapa)
  4. shown.bs.tab(i runga i te ripa katahi ano ka hohe ka whakaatuhia, he rite tonu ki tera mo te show.bs.tabtakahanga)

Mena karekau he ripa i hohe tonu, ka kore te hide.bs.tabme hidden.bs.tabnga takahanga e pana.

Momo takahanga Whakaahuatanga
whakaatu.bs.tab Ka pupuhi tenei takahanga ki te whakaaturanga ripa, engari i mua i te whakaaturanga o te ripa hou. Whakamahia event.targetme event.relatedTargette aro ki te ripa hohe me te ripa hohe o mua (mehemea kei te waatea).
whakaaturia.bs.tab Ka ahi tenei takahanga ki te whakaaturanga ripa i muri i te whakaaturanga ripa. Whakamahia event.targetme event.relatedTargette aro ki te ripa hohe me te ripa hohe o mua (mehemea kei te waatea).
huna.bs.tab Ka mura tenei takahanga ina whakaatu he ripa hou (na reira me huna te ripa hohe o mua). Whakamahievent.target me event.relatedTargette whakawhāiti i te ripa hohe onāianei me te ripa hou-hohe-hohe, ia.
huna.bs.tab Ka ahi tenei takahanga i muri i te whakaaturanga ripa hou (na reira ka huna te ripa hohe o mua). Whakamahia event.targetme event.relatedTargette aro ki te ripa hohe o mua me te ripa hohe hou.
$('a[data-toggle="list"]').on('shown.bs.tab', function (e) {
  e.target // newly activated tab
  e.relatedTarget // previous active tab
})