Tonbe
Aktive vizibilite kontni atravè pwojè ou a ak kèk klas ak grefon JavaScript nou yo.
Klike sou bouton ki anba yo pou montre ak kache yon lòt eleman atravè chanjman klas yo:
.collapse
kache kontni.collapsing
yo aplike pandan tranzisyon yo.collapse.show
montre kontni
Ou ka itilize yon lyen ak href
atribi a, oswa yon bouton ak data-target
atribi a. Nan de ka yo, data-toggle="collapse"
li nesesè.
<p>
<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
Link with href
</a>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
Button with data-target
</button>
</p>
<div class="collapse" id="collapseExample">
<div class="card card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
</div>
Yon <button>
oswa <a>
ka montre ak kache plizyè eleman lè w refere yo ak yon seleksyon JQuery nan atribi href
li yo. data-target
Plizyè <button>
oswa <a>
ka montre ak kache yon eleman si yo chak fè referans li ak atribi yo href
oswa yodata-target
<p>
<a class="btn btn-primary" data-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample2">Toggle second element</button>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button>
</p>
<div class="row">
<div class="col">
<div class="collapse multi-collapse" id="multiCollapseExample1">
<div class="card card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
</div>
</div>
<div class="col">
<div class="collapse multi-collapse" id="multiCollapseExample2">
<div class="card card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
</div>
</div>
</div>
Sèvi ak eleman kat la, ou ka pwolonje konpòtman an efondreman default yo kreye yon akòdeyon.
<div id="accordion">
<div class="card">
<div class="card-header" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Collapsible Group Item #1
</button>
</h5>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingTwo">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
Collapsible Group Item #2
</button>
</h5>
</div>
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingThree">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
Collapsible Group Item #3
</button>
</h5>
</div>
<div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
</div>
Asire ou ke ou ajoute aria-expanded
nan eleman kontwòl la. Atribi sa a eksplisitman transmèt eta aktyèl la nan eleman ki rabat la mare nan kontwòl la nan lektè ekran ak teknoloji asistans menm jan an. Si eleman plimyab la fèmen pa default, atribi sou eleman kontwòl la ta dwe gen yon valè aria-expanded="false"
. Si ou te mete eleman ki rabat la louvri pa default lè l sèvi avèk show
klas la, mete aria-expanded="true"
sou kontwòl la pito. Plugin a pral otomatikman baskile atribi sa a sou kontwòl la selon si wi ou non eleman kolapstab la te louvri oswa fèmen (via JavaScript, oswa paske itilizatè a deklanche yon lòt eleman kontwòl tou mare nan menm eleman collapsbile). Si eleman HTML eleman kontwòl la se pa yon bouton (egzanp, yon <a>
oswa <div>
), atribi arole="button"
ta dwe ajoute nan eleman an.
Si eleman kontwòl ou a ap vize yon sèl eleman ki plizye - sa vle di data-target
atribi a ap lonje dwèt sou yon id
seleksyon - ou ta dwe ajoute aria-controls
atribi a nan eleman kontwòl la, ki gen ladan id
eleman ki pliye a. Lektè ekran modèn yo ak teknoloji asistans ki sanble yo sèvi ak atribi sa a pou bay itilizatè yo rakoursi adisyonèl pou navige dirèkteman nan eleman ki rabat nan tèt li.
Remake byen ke aplikasyon Bootstrap aktyèl la pa kouvri divès kalite entèraksyon klavye ki dekri nan modèl akòdeyon WAI-ARIA Authoring Practices 1.1 - w ap bezwen mete sa yo tèt ou ak JavaScript koutim.
Plugin efondreman an itilize kèk klas pou okipe leve lou:
.collapse
kache kontni an.collapse.show
montre kontni an.collapsing
yo ajoute lè tranzisyon an kòmanse, epi li retire lè li fini
Ou ka jwenn klas sa yo nan _transitions.scss
.
Jis ajoute data-toggle="collapse"
ak yon data-target
nan eleman nan otomatikman bay kontwòl youn oswa plis eleman plim. Atribi a data-target
aksepte yon seleksyon CSS pou aplike efondreman an. Asire ou ke ou ajoute klas collapse
la nan eleman ki rabat. Si ou ta renmen li louvri defo, ajoute klas adisyonèl la show
.
Pou ajoute jesyon gwoup ki sanble ak akòdeyon nan yon zòn ki rabat, ajoute atribi done yo data-parent="#selector"
. Al gade nan Demo a pou wè sa a an aksyon.
Pèmèt manyèlman ak:
Opsyon yo ka pase atravè atribi done oswa JavaScript. Pou atribi done, ajoute non opsyon a nan data-
, tankou nan data-parent=""
.
Non | Kalite | Default | Deskripsyon |
---|---|---|---|
paran | seleksyon | jQuery objè | Eleman DOM | fo | Si yo bay paran yo, lè sa a tout eleman plimyab ki anba paran espesifye yo pral fèmen lè yo montre atik plimyab sa a. (menm jan ak konpòtman akòdeyon tradisyonèl - sa a depann sou card klas la). Gen atribi a dwe mete sou zòn nan sib eklatman. |
baskile | booleyen | vre | Aktivite eleman ki rabat sou envokasyon |
Metòd asynchrone ak tranzisyon
Tout metòd API yo asenkron epi yo kòmanse yon tranzisyon . Yo retounen kote moun k ap rele a le pli vit ke tranzisyon an kòmanse men anvan li fini . Anplis de sa, yo pral inyore yon apèl metòd sou yon eleman tranzisyon .
Aktive kontni ou kòm yon eleman plim. Aksepte yon opsyon opsyonèl object
.
Baskile yon eleman ki rabat pou montre oswa kache. Retounen bay moun k ap rele a anvan yo te montre oswa kache eleman ki rabat (sa vle di anvan evènman shown.bs.collapse
an hidden.bs.collapse
rive).
Montre yon eleman rabat. Retounen bay moun k ap rele a anvan yo te montre eleman ki rabat la (sa vle di anvan shown.bs.collapse
evènman an rive).
Kache yon eleman ki rabat. Retounen bay moun k ap rele a anvan yo te kache eleman ki rabat (sa vle di anvan hidden.bs.collapse
evènman an rive).
Detwi efondreman yon eleman.
Klas efondreman Bootstrap a ekspoze kèk evènman pou branche nan fonksyonalite efondreman.
Kalite Evènman | Deskripsyon |
---|---|
montre.bs.effondreman | Evènman sa a dife imedyatman lè yo show rele metòd egzanp lan. |
montre.bs.effondreman | Evènman sa a revoke lè yon eleman tonbe vin vizib pou itilizatè a (ap tann tranzisyon CSS yo fini). |
kache.bs.effondreman | Evènman sa a te tire imedyatman lè yo hide te rele metòd la. |
hidden.bs.effondreman | Evènman sa a revoke lè yon eleman tonbe kache nan men itilizatè a (ap tann pou tranzisyon CSS fini). |