Sau npe pawg
Cov npe pawg yog qhov hloov pauv tau thiab muaj zog rau kev nthuav tawm cov ntsiab lus. Hloov kho thiab txuas rau lawv kom txhawb nqa tsuas yog hais txog cov ntsiab lus hauv.
Piv txwv
Cov pab pawg sau npe yooj yim tshaj plaws yog cov npe tsis muaj npe nrog cov npe khoom thiab cov chav kawm tsim nyog. Ua rau nws nrog cov kev xaiv ua raws, lossis nrog koj tus kheej CSS raws li xav tau.
- Ib yam khoom
- Ib yam khoom thib ob
- Ib yam khoom thib peb
- Ib yam khoom thib plaub
- Thiab ib tug thib tsib
<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>
Cov khoom nquag
Ntxiv .active
rau qhov .list-group-item
qhia txog kev xaiv tam sim no.
- Ib yam khoom nquag
- Ib yam khoom thib ob
- Ib yam khoom thib peb
- Ib yam khoom thib plaub
- Thiab ib tug thib tsib
<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>
Cov khoom xiam oob qhab
Ntxiv .disabled
rau qhov .list-group-item
ua rau nws tshwm tsis taus. Nco ntsoov tias qee cov ntsiab lus nrog .disabled
kuj yuav xav tau kev cai JavaScript kom ua tiav lawv cov xwm txheej nyem (piv txwv li, txuas).
- Ib yam khoom xiam oob qhab
- Ib yam khoom thib ob
- Ib yam khoom thib peb
- Ib yam khoom thib plaub
- Thiab ib tug thib tsib
<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>
Txuas thiab khawm
Siv <a>
s los yog <button>
s los tsim cov npe ua haujlwm pab pawg nrog hover, disabled, thiab active xeev los ntawm kev ntxiv .list-group-item-action
. Peb cais cov pseudo-chav kawm no kom paub meej cov npe pawg ua los ntawm cov ntsiab lus tsis sib cuam tshuam (xws li <li>
s lossis <div>
s) tsis muab kev nias lossis kais them nyiaj.
Nco ntsoov tsis txhob siv cov .btn
chav kawm txheem ntawm no .
<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>
Nrog <button>
s, koj tuaj yeem siv tus disabled
cwj pwm hloov ntawm .disabled
chav kawm. Tu siab, <a>
s tsis txhawb tus cwj pwm tsis taus.
<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 button 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>
Flush
Ntxiv .list-group-flush
kom tshem tawm qee qhov ciam teb thiab cov ces kaum sib npaug los ua cov npe pawg cov khoom ntug-rau-ntug hauv lub thawv niam txiv (piv txwv li, phaib).
- Ib yam khoom
- Ib yam khoom thib ob
- Ib yam khoom thib peb
- Ib yam khoom thib plaub
- Thiab ib tug thib tsib
<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>
Tus lej
Ntxiv cov .list-group-numbered
chav kawm hloov kho (thiab xaiv tau siv ib qho <ol>
khoom siv) los xaiv rau hauv cov npe suav nrog pawg khoom. Cov lej raug tsim los ntawm CSS (raws li qhov tsis zoo rau qhov <ol>
browser styling default) rau kev tso kawm zoo dua hauv cov npe pawg khoom thiab tso cai rau kev kho kom zoo dua.
Cov lej yog tsim los ntawm counter-reset
ntawm tus <ol>
, thiab tom qab ntawd styled thiab muab tso nrog ::before
pseudo-element ntawm <li>
nrog counter-increment
thiab content
.
- Ib daim ntawv teev npe
- Ib daim ntawv teev npe
- Ib daim ntawv teev npe
<ol class="list-group list-group-numbered">
<li class="list-group-item">A list item</li>
<li class="list-group-item">A list item</li>
<li class="list-group-item">A list item</li>
</ol>
Cov no ua haujlwm zoo nrog cov ntsiab lus kev cai thiab.
-
SubheadingCov ntsiab lus rau daim ntawv teev npe
-
SubheadingCov ntsiab lus rau daim ntawv teev npe
-
SubheadingCov ntsiab lus rau daim ntawv teev npe
<ol class="list-group list-group-numbered">
<li class="list-group-item d-flex justify-content-between align-items-start">
<div class="ms-2 me-auto">
<div class="fw-bold">Subheading</div>
Content for list item
</div>
<span class="badge bg-primary rounded-pill">14</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-start">
<div class="ms-2 me-auto">
<div class="fw-bold">Subheading</div>
Content for list item
</div>
<span class="badge bg-primary rounded-pill">14</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-start">
<div class="ms-2 me-auto">
<div class="fw-bold">Subheading</div>
Content for list item
</div>
<span class="badge bg-primary rounded-pill">14</span>
</li>
</ol>
Kab rov tav
Ntxiv .list-group-horizontal
los hloov qhov layout ntawm cov npe pawg cov khoom los ntawm ntsug mus rau kab rov tav hla txhua qhov kev tawg. Xwb, xaiv ib qho kev hloov pauv .list-group-horizontal-{sm|md|lg|xl|xxl}
los ua cov npe pawg kab rov tav pib ntawm qhov kev ncua ntawd min-width
. Tam sim no kab rov tav cov npe pawg tsis tuaj yeem ua ke nrog cov pab pawg flush.
ProTip: Koj puas xav tau cov khoom sib npaug-dav sib npaug ntawm cov khoom thaum kab rov tav? Ntxiv .flex-fill
rau txhua pab pawg cov khoom.
- Ib yam khoom
- Ib yam khoom thib ob
- Ib yam khoom thib peb
- Ib yam khoom
- Ib yam khoom thib ob
- Ib yam khoom thib peb
- Ib yam khoom
- Ib yam khoom thib ob
- Ib yam khoom thib peb
- Ib yam khoom
- Ib yam khoom thib ob
- Ib yam khoom thib peb
- Ib yam khoom
- Ib yam khoom thib ob
- Ib yam khoom thib peb
- Ib yam khoom
- Ib yam khoom thib ob
- Ib yam khoom thib peb
<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>
<ul class="list-group list-group-horizontal-xxl">
<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>
Cov chav kawm ntawm cov ntsiab lus
Siv cov chav kawm hauv cov ntsiab lus los tsim cov npe khoom nrog cov keeb kwm yav dhau los thiab xim.
- Ib qho yooj yim default list pawg khoom
- Ib qho yooj yim thawj pab pawg cov khoom
- Ib qho yooj yim thib ob daim ntawv teev npe pab pawg
- Ib qho yooj yim daim ntawv teev npe pab pawg yam khoom
- Ib daim ntawv teev cov khoom txaus ntshai yooj yim
- Ib qho yooj yim ceeb toom pab pawg cov khoom
- Ib qho yooj yim cov ntaub ntawv sau npe pawg khoom
- Ib qho yooj yim lub teeb daim ntawv teev cov khoom
- Ib qho yooj yim dark list pawg khoom
<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>
Cov chav kawm ntawv ntsiab lus kuj ua haujlwm nrog .list-group-item-action
. Nco ntsoov qhov sib ntxiv ntawm cov hover styles ntawm no tsis muaj nyob rau hauv qhov piv txwv yav dhau los. Kuj txhawb yog lub .active
xeev; siv nws los qhia txog qhov kev xaiv ua haujlwm ntawm cov npe ntawm cov ntsiab lus ntawm pawg khoom.
<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>
Qhia lub ntsiab lus rau kev pab technologies
Siv cov xim los ntxiv cov ntsiab lus tsuas yog muab qhov pom kev pom, uas yuav tsis raug xa mus rau cov neeg siv cov thev naus laus zis pab - xws li cov ntawv nyeem. Xyuas kom meej tias cov ntaub ntawv qhia los ntawm cov xim yog pom tseeb los ntawm cov ntsiab lus nws tus kheej (xws li cov ntawv pom), lossis suav nrog lwm txoj kev, xws li cov ntawv ntxiv zais nrog cov .visually-hidden
chav kawm.
Nrog cov paib
Ntxiv cov paib rau ib pawg ntawm cov npe khoom kom pom cov lej tsis tau nyeem, kev ua ub no, thiab ntau ntxiv nrog kev pab los ntawm qee cov khoom siv hluav taws xob .
- Ib daim ntawv teev npe14
- Ib yam khoom thib ob2
- Ib yam khoom thib peb1
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center">
A list item
<span class="badge bg-primary rounded-pill">14</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
A second list item
<span class="badge bg-primary rounded-pill">2</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
A third list item
<span class="badge bg-primary rounded-pill">1</span>
</li>
</ul>
Kev cai cov ntsiab lus
Ntxiv ze li ntawm HTML nyob rau hauv, txawm rau cov pab pawg sib txuas xws li ib qho hauv qab no, nrog kev pab ntawm flexbox utilities .
Sau npe pab pawg kab lus
3 hnub dhau losQee qhov chaw muab cov ntsiab lus hauv ib kab lus.
Thiab ib co ntawv me me.Sau npe pab pawg kab lus
3 hnub dhau losQee qhov chaw muab cov ntsiab lus hauv ib kab lus.
Thiab ib co muted me print.Sau npe pab pawg kab lus
3 hnub dhau losQee qhov chaw muab cov ntsiab lus hauv ib kab lus.
Thiab ib co muted me print.<div class="list-group">
<a href="#" class="list-group-item list-group-item-action active" aria-current="true">
<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>
Checkboxes thiab xov tooj cua
Muab Bootstrap lub checkboxes thiab xov tooj cua nyob rau hauv cov npe pawg khoom thiab kho raws li xav tau. Koj tuaj yeem siv lawv yam tsis muaj <label>
s, tab sis thov nco ntsoov suav nrog tus aria-label
cwj pwm thiab tus nqi rau kev siv tau.
<ul class="list-group">
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="firstCheckbox">
<label class="form-check-label" for="firstCheckbox">First checkbox</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="secondCheckbox">
<label class="form-check-label" for="secondCheckbox">Second checkbox</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="thirdCheckbox">
<label class="form-check-label" for="thirdCheckbox">Third checkbox</label>
</li>
</ul>
<ul class="list-group">
<li class="list-group-item">
<input class="form-check-input me-1" type="radio" name="listGroupRadio" value="" id="firstRadio" checked>
<label class="form-check-label" for="firstRadio">First radio</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="radio" name="listGroupRadio" value="" id="secondRadio">
<label class="form-check-label" for="secondRadio">Second radio</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="radio" name="listGroupRadio" value="" id="thirdRadio">
<label class="form-check-label" for="thirdRadio">Third radio</label>
</li>
</ul>
Koj tuaj yeem siv .stretched-link
rau ntawm <label>
s los ua kom tag nrho cov npe pawg khoom clickable.
<ul class="list-group">
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="firstCheckboxStretched">
<label class="form-check-label stretched-link" for="firstCheckboxStretched">First checkbox</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="secondCheckboxStretched">
<label class="form-check-label stretched-link" for="secondCheckboxStretched">Second checkbox</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="thirdCheckboxStretched">
<label class="form-check-label stretched-link" for="thirdCheckboxStretched">Third checkbox</label>
</li>
</ul>
CSS
Hloov pauv
Ntxiv hauv v5.2.0Raws li ib feem ntawm Bootstrap qhov hloov pauv CSS hloov pauv mus kom ze, cov npe pawg tam sim no siv cov CSS hauv zos .list-group
rau kev hloov kho lub sijhawm tiag tiag. Cov txiaj ntsig rau CSS qhov sib txawv tau teeb tsa ntawm Sass, yog li Sass customization tseem txhawb nqa, ib yam nkaus.
--#{$prefix}list-group-color: #{$list-group-color};
--#{$prefix}list-group-bg: #{$list-group-bg};
--#{$prefix}list-group-border-color: #{$list-group-border-color};
--#{$prefix}list-group-border-width: #{$list-group-border-width};
--#{$prefix}list-group-border-radius: #{$list-group-border-radius};
--#{$prefix}list-group-item-padding-x: #{$list-group-item-padding-x};
--#{$prefix}list-group-item-padding-y: #{$list-group-item-padding-y};
--#{$prefix}list-group-action-color: #{$list-group-action-color};
--#{$prefix}list-group-action-hover-color: #{$list-group-action-hover-color};
--#{$prefix}list-group-action-hover-bg: #{$list-group-hover-bg};
--#{$prefix}list-group-action-active-color: #{$list-group-action-active-color};
--#{$prefix}list-group-action-active-bg: #{$list-group-action-active-bg};
--#{$prefix}list-group-disabled-color: #{$list-group-disabled-color};
--#{$prefix}list-group-disabled-bg: #{$list-group-disabled-bg};
--#{$prefix}list-group-active-color: #{$list-group-active-color};
--#{$prefix}list-group-active-bg: #{$list-group-active-bg};
--#{$prefix}list-group-active-border-color: #{$list-group-active-border-color};
Sass variables
$list-group-color: $gray-900;
$list-group-bg: $white;
$list-group-border-color: rgba($black, .125);
$list-group-border-width: $border-width;
$list-group-border-radius: $border-radius;
$list-group-item-padding-y: $spacer * .5;
$list-group-item-padding-x: $spacer;
$list-group-item-bg-scale: -80%;
$list-group-item-color-scale: 40%;
$list-group-hover-bg: $gray-100;
$list-group-active-color: $component-active-color;
$list-group-active-bg: $component-active-bg;
$list-group-active-border-color: $list-group-active-bg;
$list-group-disabled-color: $gray-600;
$list-group-disabled-bg: $list-group-bg;
$list-group-action-color: $gray-700;
$list-group-action-hover-color: $list-group-action-color;
$list-group-action-active-color: $body-color;
$list-group-action-active-bg: $gray-200;
Mixins
Siv ua ke nrog $theme-colors
los tsim cov ntsiab lus sib txawv ntawm cov chav kawm rau .list-group-item
s.
@mixin list-group-item-variant($state, $background, $color) {
.list-group-item-#{$state} {
color: $color;
background-color: $background;
&.list-group-item-action {
&:hover,
&:focus {
color: $color;
background-color: shade-color($background, 10%);
}
&.active {
color: $white;
background-color: $color;
border-color: $color;
}
}
}
}
Loop
Loop uas tsim cov chav kawm hloov kho nrog cov list-group-item-variant()
mixin.
// List group contextual variants
//
// Add modifier classes to change text and background color on individual items.
// Organizationally, this must come after the `:hover` states.
@each $state, $value in $theme-colors {
$list-group-variant-bg: shift-color($value, $list-group-item-bg-scale);
$list-group-variant-color: shift-color($value, $list-group-item-color-scale);
@if (contrast-ratio($list-group-variant-bg, $list-group-variant-color) < $min-contrast-ratio) {
$list-group-variant-color: mix($value, color-contrast($list-group-variant-bg), abs($list-group-item-color-scale));
}
@include list-group-item-variant($state, $list-group-variant-bg, $list-group-variant-color);
}
JavaScript cwj pwm
Siv lub tab JavaScript plugin - suav nrog nws tus kheej lossis los ntawm cov ntaub ntawv sau ua ke bootstrap.js
- txhawm rau txuas peb cov npe pawg los tsim cov tabbable panes ntawm cov ntsiab lus hauv zos.
<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-bs-toggle="list" href="#list-home" role="tab" aria-controls="list-home">Home</a>
<a class="list-group-item list-group-item-action" id="list-profile-list" data-bs-toggle="list" href="#list-profile" role="tab" aria-controls="list-profile">Profile</a>
<a class="list-group-item list-group-item-action" id="list-messages-list" data-bs-toggle="list" href="#list-messages" role="tab" aria-controls="list-messages">Messages</a>
<a class="list-group-item list-group-item-action" id="list-settings-list" data-bs-toggle="list" href="#list-settings" role="tab" aria-controls="list-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>
Siv cov ntaub ntawv tus cwj pwm
Koj tuaj yeem qhib cov npe pab pawg navigation yam tsis tau sau ib qho JavaScript los ntawm kev qhia yooj yim data-bs-toggle="list"
lossis ntawm lub ntsiab lus. Siv cov ntaub ntawv tus cwj pwm ntawm .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-bs-toggle="list" href="#home" role="tab">Home</a>
<a class="list-group-item list-group-item-action" data-bs-toggle="list" href="#profile" role="tab">Profile</a>
<a class="list-group-item list-group-item-action" data-bs-toggle="list" href="#messages" role="tab">Messages</a>
<a class="list-group-item list-group-item-action" data-bs-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>
Ntawm JavaScript
Pab kom tabbable cov npe khoom ntawm JavaScript (txhua daim ntawv teev npe yuav tsum tau qhib ib tus zuj zus):
const triggerTabList = document.querySelectorAll('#myTab a')
triggerTabList.forEach(triggerEl => {
const tabTrigger = new bootstrap.Tab(triggerEl)
triggerEl.addEventListener('click', event => {
event.preventDefault()
tabTrigger.show()
})
})
Koj tuaj yeem qhib cov npe ntawm tus kheej hauv ntau txoj hauv kev:
const triggerEl = document.querySelector('#myTab a[href="#profile"]')
bootstrap.Tab.getInstance(triggerEl).show() // Select tab by name
const triggerFirstTabEl = document.querySelector('#myTab li:first-child a')
bootstrap.Tab.getInstance(triggerFirstTabEl).show() // Select first tab
Fade nyhuv
Txhawm rau ua kom lub vaj huam sib luag ploj mus, ntxiv .fade
rau txhua qhov .tab-pane
. Thawj tab pane yuav tsum tau .show
ua kom pom cov ntsiab lus thawj zaug.
<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>
Cov txheej txheem
Asynchronous txoj kev thiab kev hloov
Txhua txoj kev API yog asynchronous thiab pib hloov pauv . Lawv rov qab mus rau tus neeg hu xov tooj sai li sai tau thaum qhov kev hloov pauv pib tab sis ua ntej nws xaus . Tsis tas li ntawd, ib txoj kev hu rau ib qho kev hloov pauv yuav raug tsis quav ntsej .
Qhib koj cov ntsiab lus raws li lub ntsiab tab.
Koj tuaj yeem tsim ib qho piv txwv nrog tus tsim, piv txwv li:
const bsTab = new bootstrap.Tab('#myTab')
Txoj kev | Kev piav qhia |
---|---|
dispose |
Ua kom puas lub ntsiab tab. |
getInstance |
Txoj kev zoo li qub uas tso cai rau koj kom tau txais qhov piv txwv tab cuam tshuam nrog DOM lub caij, koj tuaj yeem siv nws zoo li no: bootstrap.Tab.getInstance(element) . |
getOrCreateInstance |
Txoj kev zoo li qub uas rov qab ib qho piv txwv cuam tshuam rau DOM lub caij lossis tsim ib qho tshiab yog tias nws tsis tau pib. Koj tuaj yeem siv nws li no: bootstrap.Tab.getOrCreateInstance(element) . |
show |
Xaiv qhov muab tab thiab qhia nws cov kab sib txuas. Lwm lub tab uas tau xaiv yav dhau los yuav tsis raug xaiv thiab nws cov pane cuam tshuam tau muab zais. Rov qab mus rau tus neeg hu ua ntej lub tab pane tau tshwm sim tiag tiag (piv txwv li ua ntej qhov shown.bs.tab xwm txheej tshwm sim). |
Cov xwm txheej
Thaum pom ib lub tab tshiab, cov xwm txheej hluav taws kub hauv qhov kev txiav txim hauv qab no:
hide.bs.tab
(ntawm lub tab active tam sim no)show.bs.tab
(ntawm qhov yuav tsum tau qhia tab)hidden.bs.tab
(nyob rau yav dhau los active tab, tib yam li rau qhovhide.bs.tab
kev tshwm sim)shown.bs.tab
(ntawm lub tab tshiab uas nyuam qhuav tshwm sim, tib yam li rau qhovshow.bs.tab
kev tshwm sim)
Yog tias tsis muaj tab twb ua haujlwm lawm, ces cov xwm txheej hide.bs.tab
thiab hidden.bs.tab
cov xwm txheej yuav tsis raug rho tawm haujlwm.
Hom xwm txheej | Kev piav qhia |
---|---|
hide.bs.tab |
Qhov kev tshwm sim no tua hluav taws thaum lub tab tshiab yuav tsum tau tshwm sim (thiab yog li lub tab yav dhau los yuav tsum tau muab zais). Siv event.target thiab event.relatedTarget tsom rau cov tab tam sim no thiab cov tshiab sai sai-rau-yuav-ua haujlwm tab, feem. |
hidden.bs.tab |
Qhov kev tshwm sim no tshwm sim tom qab lub tab tshiab tau tshwm sim (thiab yog li lub tab active yav dhau los tau muab zais). Siv event.target thiab event.relatedTarget tsom mus rau lub tab active yav dhau los thiab cov tshiab tab tshiab, raws li. |
show.bs.tab |
Qhov kev tshwm sim no tua hluav taws ntawm tab qhia, tab sis ua ntej tab tshiab tau tshwm sim. Siv event.target thiab event.relatedTarget tsom rau lub tab active thiab yav dhau los active tab (yog tias muaj) feem. |
shown.bs.tab |
Qhov kev tshwm sim no tua hluav taws ntawm tab qhia tom qab tau pom tab. Siv event.target thiab event.relatedTarget tsom rau lub tab active thiab yav dhau los active tab (yog tias muaj) feem. |
const tabElms = document.querySelectorAll('a[data-bs-toggle="list"]')
tabElms.forEach(tabElm => {
tabElm.addEventListener('shown.bs.tab', event => {
event.target // newly activated tab
event.relatedTarget // previous active tab
})
})