Rōpū rārangi
Ko nga roopu rarangi he waahanga ngawari me te kaha mo te whakaatu i te 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.
- He taonga
- He mea tuarua
- He mea tuatoru
- He mea tuawha
- Me te tuarima
<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>
Tūemi hohe
Tāpirihia .active
ki a .list-group-item
hei tohu i te tīpakonga hohe onāianei.
- He tūemi hohe
- He mea tuarua
- He mea tuatoru
- He mea tuawha
- Me te tuarima
<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>
Ko nga mea kua monokia
Taapirihia .disabled
ki .list-group-item
a kia ahua monokia. Kia mahara ko etahi o nga huānga me .disabled
te hiahia hoki ki te JavaScript ritenga ki te whakakore i a raatau kaupapa paato (hei tauira, hononga).
- He mea monokia
- He mea tuarua
- He mea tuatoru
- He mea tuawha
- Me te tuarima
<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>
Hononga me nga paatene
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 .btn
karaehe paerewa i konei .
<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>
Ki <button>
te s, ka taea hoki e koe te whakamahi i te disabled
huanga hei utu mo te .disabled
akomanga. 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" aria-current="true">
The current button
</button>
<button type="button" class="list-group-item list-group-item-action">A second 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>
Horoi
Taapirihia .list-group-flush
hei 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).
- He taonga
- He mea tuarua
- He mea tuatoru
- He mea tuawha
- Me te tuarima
<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>
Whakapae
Tāpirihia .list-group-horizontal
hei huri i te tahora o te rārangi tūemi rōpū mai i te poutū ki te whakapae puta noa i ngā wāhi wehenga katoa. Arā, kōwhiria he rerekētanga aro .list-group-horizontal-{sm|md|lg|xl}
ki te whakapaepae i tētahi rōpū rārangi ka tīmata mai i taua wāhi wehenga min-width
. I tenei wa kaore e taea te whakakotahi i nga roopu rarangi whakapae me nga roopu rarangi reera.
ProTip: Kei te pirangi koe ki nga taonga roopu roopu rite-whanui ina whakapae? Tāpirihia .flex-fill
ki ia rārangi tūemi rōpū.
- He taonga
- He mea tuarua
- He mea tuatoru
- He taonga
- He mea tuarua
- He mea tuatoru
- He taonga
- He mea tuarua
- He mea tuatoru
- He taonga
- He mea tuarua
- He mea tuatoru
- He taonga
- He mea tuarua
- He mea tuatoru
<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>
Nga karaehe horopaki
Whakamahia nga karaehe horopaki ki te whakaahua i nga mea rarangi ingoa me te papamuri me te tae.
- He tuemi rarangi taunoa ngawari
- 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">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>
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 .active
kawanatanga; 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">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>
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-only
akomanga.
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 .
- He mea rarangi14
- He tuemi rarangi tuarua2
- He rarangi rarangi tuatoru1
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center">
A list item
<span class="badge badge-primary badge-pill">14</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
A second list item
<span class="badge badge-primary badge-pill">2</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
A third list item
<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 .
Whakarārangihia te upoko tūemi rōpū
3 ra ki muriKo etahi ihirangi puri wahi i roto i te whiti.
Me etahi tuhinga iti.Whakarārangihia te upoko tūemi rōpū
3 ra ki muriKo etahi ihirangi puri wahi i roto i te whiti.
A ko etahi i wahangu i nga tuhinga iti.Whakarārangihia te upoko tūemi rōpū
3 ra ki muriKo etahi ihirangi puri wahi i roto i te whiti.
A ko etahi i wahangu i nga tuhinga iti.<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">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>
Te whanonga JavaScript
Whakamahia te ripa JavaScript mono—whakauruhia takitahi, na roto ranei i te bootstrap.js
konae 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
.
<div role="tabpanel">
<!-- 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>
</div>
Ma te JavaScript
Whakahohehia te tuemi rarangi ripa ma te JavaScript (me whakahohe takitahi ia rarangi tuemi):
$('#myList a').on('click', function (event) {
event.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 .fade
ki ia .tab-pane
. Ko te pihanga ripa tuatahi me .show
whakaatu 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 href
kohanga 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.tab
puta 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:
hide.bs.tab
(i runga i te ripa hohe onāianei)show.bs.tab
(i runga i te ripa hei whakaatu)hidden.bs.tab
(i runga i te ripa hohe o mua, he rite ki tehide.bs.tab
kaupapa)shown.bs.tab
(i runga i te ripa katahi ano ka hohe ka whakaatuhia, he rite tonu ki tera mo teshow.bs.tab
takahanga)
Mena karekau he ripa i hohe tonu, ka kore te hide.bs.tab
me hidden.bs.tab
nga 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.target me event.relatedTarget te 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.target me event.relatedTarget te aro ki te ripa hohe me te ripa hohe o mua (mehemea kei te waatea). |
huna.bs.tab | Ka puhipuhi tenei takahanga ina whakaatuhia he ripa hou (na reira me huna te ripa hohe o mua). Whakamahia event.target me event.relatedTarget te 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.target me event.relatedTarget te aro ki te ripa hohe o mua me te ripa hohe hou. |
$('a[data-toggle="list"]').on('shown.bs.tab', function (event) {
event.target // newly activated tab
event.relatedTarget // previous active tab
})