Bootstrap 4 JS Çöküşü
CSS Sınıflarını Daralt
Collapsibles hakkında bir eğitim için Bootstrap Collapse Eğitimimizi okuyun .
Class | Description | Example |
---|---|---|
.collapse |
Hides the content | |
.collapse show |
Shows the collapsible content by default | |
.collapsing |
Added when the transition starts, and removed when it finishes |
Veri-* Öznitelikler aracılığıyla
Katlanabilir bir öğenin kontrolünü otomatik olarak atamak için bir öğeye data-toggle="collapse"
ve bir öğeye eklemeniz yeterlidir. data-target
data-target niteliği, daraltmanın uygulanacağı bir CSS seçiciyi kabul eder. Daraltılabilir öğeye sınıf daraltmasını eklediğinizden emin olun. Varsayılan olarak açılmasını istiyorsanız, "show" ek sınıfını ekleyin.
Örnek
<button class="btn" data-toggle="collapse" data-target="#demo">Collapsible</button>
<div id="demo" class="collapse">
Some text..
</div>
İpucu: Daraltılabilir bir denetime akordeon benzeri grup yönetimi eklemek için data-parent="#selector" veri özniteliğini ekleyin.
JavaScript aracılığıyla
Şunlarla manuel olarak etkinleştirin:
$('.collapse').collapse()
Seçenekleri Daralt
Seçenekler, veri öznitelikleri veya JavaScript aracılığıyla iletilebilir. Veri öznitelikleri için, data-parent="" gibi seçenek adını data- öğesine ekleyin.
Name | Type | Default | Description | Try it |
---|---|---|---|---|
parent | selector | false | All collapsible elements under the specified parent will be closed when this collapsible item is shown. (similar to traditional accordion behavior) | |
toggle | boolean | true | Toggles the collapsible element on invocation |
Daraltma Yöntemleri
Aşağıdaki tablo, mevcut tüm daraltma yöntemlerini listeler.
Method | Description | Try it |
---|---|---|
.collapse(options) | Activates the collapsible element with an option. See options above for valid values | |
.collapse("toggle") | Toggles the collapsible element | |
.collapse("show") | Shows the collapsible element | |
.collapse("hide") | Hides the collapsible element | |
.collapse("dispose") | Destroys the collapsible element |
Olayları Daralt
Aşağıdaki tablo, mevcut tüm daraltma olaylarını listeler.
Event | Description | Try it |
---|---|---|
show.bs.collapse | Occurs when the collapsible element is about to be shown | |
shown.bs.collapse | Occurs when the collapsible element is fully shown (after CSS transitions have completed) | |
hide.bs.collapse | Occurs when the collapsible element is about to be hidden | |
hidden.bs.collapse | Occurs when the collapsible element is fully hidden (after CSS transitions have completed) |