Deňiz we bellikler
“Bootstrap” -yň goşulan nawigasiýa komponentlerini nädip ulanmalydygy barada resminamalar we mysallar.
Esasy nav
.nav
“Bootstrap” -da bar bolan nawigasiýa, esasy synpdan işjeň we maýyp ýagdaýlara çenli umumy bellikleri we stilleri paýlaşýar . Her stiliň arasynda geçmek üçin üýtgediji synplary çalyşyň.
Esasy .nav
komponent flexbox bilen gurlup, ähli nawigasiýa komponentlerini gurmak üçin berk binýady üpjün edýär. Onda käbir stil ýazgylary (sanawlar bilen işlemek üçin), has uly urlan ýerler üçin käbir baglanyşyk paddingleri we esasy maýyp stilleri bar.
Esasy .nav
komponent haýsydyr bir ýagdaýy öz içine almaýar .active
. Aşakdaky mysallar, esasanam bu aýratyn synpyň hiç hili ýörite stil döretmeýändigini görkezmek üçin synpy öz içine alýar.
Işjeň ýagdaýy kömekçi tehnologiýalara ýetirmek üçin aria-current
atributdan peýdalanyň - häzirki sahypa ýa -da toplumdaky häzirki element üçin page
bahany ulanyň.true
<ul class="nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Sapaklar hemme ýerde ulanylýar, şonuň üçin belligiňiz gaty çeýe bolup biler. Harytlaryňyzyň tertibi möhüm bolsa, <ul>
ýokardaky ýaly s ulanyň ýa-da bir element bilen özüňizi aýlaň. Ulanylyşy sebäpli , nav baglanyşyklary nav elementleri ýaly hereket edýär, ýöne goşmaça bellik bolmazdan.<ol>
<nav>
.nav
display: flex
<nav class="nav">
<a class="nav-link active" aria-current="page" href="#">Active</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled">Disabled</a>
</nav>
Elýeterli stiller
S komponentiniň stilini .nav
üýtgedijiler we kömekçi enjamlar bilen üýtgediň. Zerur bolanda garyşdyryň we deňeşdiriň ýa-da özüňiz guruň.
Gorizontal deňleşdirme
“Navbox” -yň gorizontal deňleşmesini “ flexbox” enjamlary bilen üýtgediň . Düzgüne görä, deňiz güýçleri çep hatara düzülendir, ýöne olary aňsatlyk bilen merkeze ýa-da sag tarapa üýtgedip bilersiňiz.
Merkezde .justify-content-center
:
<ul class="nav justify-content-center">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Sag bilen deňleşdirilen .justify-content-end
:
<ul class="nav justify-content-end">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Dik
Utgaşma bilen flex elementiň ugruny üýtgedip, nawigasiýaňyzy düzüň .flex-column
. Olary käbir görnüşlerde ýerleşdirmeli, ýöne beýlekiler däl? Duýgur wersiýalary ulanyň (mysal üçin .flex-sm-column
).
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Hemişe bolşy ýaly, wertikal nawigasiýa <ul>
s bolmasa-da mümkindir.
<nav class="nav flex-column">
<a class="nav-link active" aria-current="page" href="#">Active</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled">Disabled</a>
</nav>
Salgylar
Esasy deňizden ýokardan alýar we goýlan .nav-tabs
interfeýs döretmek üçin synpy goşýar. JavaScript pluginimiz bilen tablisa sebitlerini döretmek üçin ulanyň .
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Dermanlar
Şol bir HTML alyň, ýöne .nav-pills
ýerine ulanyň:
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Doldur we akla
.nav
Mazmunyňyzy iki üýtgediji synpyň biriniň elýeterli giňligini giňeltmäge mejbur ediň . Bar bolan ýerleri proporsional taýdan doldurmak üçin .nav-item
ulanyň .nav-fill
. Horhli gorizontal giňişligiň eýeleýändigine üns beriň, ýöne her bir deňiz elementiniň birmeňzeş giňligi ýok.
<ul class="nav nav-pills nav-fill">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Much longer nav link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
<nav>
Esasy nawigasiýa ulanylanda, .nav-item
diňe stil elementleri .nav-link
üçin talap edilişi ýaly arkaýyn goýup bilersiňiz.<a>
<nav class="nav nav-pills nav-fill">
<a class="nav-link active" aria-current="page" href="#">Active</a>
<a class="nav-link" href="#">Much longer nav link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled">Disabled</a>
</nav>
Deň giňlikdäki elementler üçin ulanyň .nav-justified
. Horhli gorizontal giňişlik deňiz baglanyşyklary bilen tutular, ýöne .nav-fill
ýokardakylardan tapawutlylykda her deňiz elementi birmeňzeş giňlikde bolar.
<ul class="nav nav-pills nav-justified">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Much longer nav link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Esasy nawigasiýa .nav-fill
ulanmak mysalyna meňzeýär .<nav>
<nav class="nav nav-pills nav-justified">
<a class="nav-link active" aria-current="page" href="#">Active</a>
<a class="nav-link" href="#">Much longer nav link</a>
<a class="nav-link" href="#">Link</a>
<a class="nav-link disabled">Disabled</a>
</nav>
Flex kömekçi enjamlar bilen işlemek
Size jogap beriji üýtgeşiklikler gerek bolsa, flexbox kömekçi enjamlarynyň bir toparyny ulanmagy göz öňünde tutuň . Has köp sözli bolsa-da, bu kömekçi enjamlar jogap beriş nokatlarynda has uly özleşdirme hödürleýär. Aşakdaky mysalda, deňiz ýolumyz iň pes nokada ýerleşdiriler, soňra kiçi nokatdan başlap elýeterli giňligi doldurýan keseligine ýerleşer.
<nav class="nav nav-pills flex-column flex-sm-row">
<a class="flex-sm-fill text-sm-center nav-link active" aria-current="page" href="#">Active</a>
<a class="flex-sm-fill text-sm-center nav-link" href="#">Longer nav link</a>
<a class="flex-sm-fill text-sm-center nav-link" href="#">Link</a>
<a class="flex-sm-fill text-sm-center nav-link disabled">Disabled</a>
</nav>
Elýeterlilik barada
Nawigasiýa zolagyny üpjün etmek üçin deňiz güýçlerini ulanýan bolsaňyz role="navigation"
, iň logiki ene konteýnerine goşuň <ul>
ýa-da <nav>
tutuş nawigasiýa elementini gurşap alyň. Roly özüne goşmaň <ul>
, sebäbi bu kömekçi tehnologiýalar arkaly hakyky sanaw hökmünde yglan edilmeginiň öňüni alar.
Nawigasiýa panelleriniň, hatda .nav-tabs
synp bilen tablisa görnüşinde görnüp dursa-da, berilmeli däldigini ýarole="tablist"
- role="tab"
da role="tabpanel"
atributlarynyň bolmaly däldigini unutmaň. Bular diňe ARIA Awtorlaşdyryş Amallary Gollanmasy tablisa görnüşinde beýan edilişi ýaly dinamiki goýlan interfeýsler üçin laýyk gelýär . Mysal üçin bu bölümdäki dinamiki goýlan interfeýsler üçin JavaScript häsiýetine serediň . Aýratynlyk dinamiki goýlan interfeýslerde hökmany däl, sebäbi JavaScript işjeň goýmany aria-current
goşmak bilen saýlanan ýagdaýy dolandyrýar .aria-selected="true"
Açylýan ýerleri ulanmak
Birneme goşmaça HTML we açylan JavaScript plugin bilen açylýan menýulary goşuň .
Açylýan bellikler
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">Dropdown</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
Açylýan dermanlar
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Active</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false">Dropdown</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled">Disabled</a>
</li>
</ul>
CSS
Üýtgeýjiler
V5.2.0 goşuldy“Bootstrap” -yň ösýän CSS üýtgeýjileriniň çemeleşmesiniň bir bölegi hökmünde, deňiz güýçleri häzirki wagtda ýerli CSS üýtgeýjileri ulanýarlar we hakyky .nav
wagtda özleşdirmek üçin. CSS üýtgeýjileriniň bahalary Sass arkaly kesgitlenýär, şonuň üçin Sass sazlamasy henizem goldanýar..nav-tabs
.nav-pills
Esasy .nav
synpda:
--#{$prefix}nav-link-padding-x: #{$nav-link-padding-x};
--#{$prefix}nav-link-padding-y: #{$nav-link-padding-y};
@include rfs($nav-link-font-size, --#{$prefix}nav-link-font-size);
--#{$prefix}nav-link-font-weight: #{$nav-link-font-weight};
--#{$prefix}nav-link-color: #{$nav-link-color};
--#{$prefix}nav-link-hover-color: #{$nav-link-hover-color};
--#{$prefix}nav-link-disabled-color: #{$nav-link-disabled-color};
Üýtgediji .nav-tabs
synpda:
--#{$prefix}nav-tabs-border-width: #{$nav-tabs-border-width};
--#{$prefix}nav-tabs-border-color: #{$nav-tabs-border-color};
--#{$prefix}nav-tabs-border-radius: #{$nav-tabs-border-radius};
--#{$prefix}nav-tabs-link-hover-border-color: #{$nav-tabs-link-hover-border-color};
--#{$prefix}nav-tabs-link-active-color: #{$nav-tabs-link-active-color};
--#{$prefix}nav-tabs-link-active-bg: #{$nav-tabs-link-active-bg};
--#{$prefix}nav-tabs-link-active-border-color: #{$nav-tabs-link-active-border-color};
Üýtgediji .nav-pills
synpda:
--#{$prefix}nav-pills-border-radius: #{$nav-pills-border-radius};
--#{$prefix}nav-pills-link-active-color: #{$nav-pills-link-active-color};
--#{$prefix}nav-pills-link-active-bg: #{$nav-pills-link-active-bg};
Sass üýtgeýjileri
$nav-link-padding-y: .5rem;
$nav-link-padding-x: 1rem;
$nav-link-font-size: null;
$nav-link-font-weight: null;
$nav-link-color: var(--#{$prefix}link-color);
$nav-link-hover-color: var(--#{$prefix}link-hover-color);
$nav-link-transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out;
$nav-link-disabled-color: $gray-600;
$nav-tabs-border-color: $gray-300;
$nav-tabs-border-width: $border-width;
$nav-tabs-border-radius: $border-radius;
$nav-tabs-link-hover-border-color: $gray-200 $gray-200 $nav-tabs-border-color;
$nav-tabs-link-active-color: $gray-700;
$nav-tabs-link-active-bg: $body-bg;
$nav-tabs-link-active-border-color: $gray-300 $gray-300 $nav-tabs-link-active-bg;
$nav-pills-border-radius: $border-radius;
$nav-pills-link-active-color: $component-active-color;
$nav-pills-link-active-bg: $component-active-bg;
JavaScript häsiýeti
bootstrap.js
Javaerli mazmunyň tablisa panellerini döretmek üçin nawigasiýa belliklerimizi we tabletkalarymyzy giňeltmek üçin JavaScript pluginini ulanyň - ony aýratyn ýa-da düzülen faýl arkaly goşuň.
Bu, Öý goýmasynyň baglanyşykly mazmuny. Başga bir düwmä bassaňyz, indiki üçin görnükliligini üýtgeder. JavaScript goýmasy, mazmunyň görünmegine we stiline gözegçilik etmek üçin sapaklary çalyşýar. Salgylar, dermanlar we beýleki .nav
güýçli nawigasiýa bilen ulanyp bilersiňiz.
This is some placeholder content the Profile tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav
-powered navigation.
This is some placeholder content the Contact tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav
-powered navigation.
This is some placeholder content the Disabled tab's associated content.
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home-tab-pane" type="button" role="tab" aria-controls="home-tab-pane" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile-tab-pane" type="button" role="tab" aria-controls="profile-tab-pane" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#contact-tab-pane" type="button" role="tab" aria-controls="contact-tab-pane" aria-selected="false">Contact</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="disabled-tab" data-bs-toggle="tab" data-bs-target="#disabled-tab-pane" type="button" role="tab" aria-controls="disabled-tab-pane" aria-selected="false" disabled>Disabled</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home-tab-pane" role="tabpanel" aria-labelledby="home-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="profile-tab-pane" role="tabpanel" aria-labelledby="profile-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="contact-tab-pane" role="tabpanel" aria-labelledby="contact-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="disabled-tab-pane" role="tabpanel" aria-labelledby="disabled-tab" tabindex="0">...</div>
</div>
Islegleriňize laýyk gelmek üçin, <ul>
ýokarda görkezilişi ýaly esasly bellik bilen ýa-da islendik özbaşdak “özüňizi belläň” belligi bilen işleýär. Ulanylýan bolsaňyz <nav>
, oňa gönüden-göni goşmaly däldigiňize üns beriň role="tablist"
, sebäbi bu elementiň nawigasiýa belligi hökmünde ýerli roluny ýok eder. Munuň ýerine alternatiw elemente geçiň (aşakdaky mysalda ýönekeý <div>
) we <nav>
daşyny gurşap alyň.
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<button class="nav-link active" id="nav-home-tab" data-bs-toggle="tab" data-bs-target="#nav-home" type="button" role="tab" aria-controls="nav-home" aria-selected="true">Home</button>
<button class="nav-link" id="nav-profile-tab" data-bs-toggle="tab" data-bs-target="#nav-profile" type="button" role="tab" aria-controls="nav-profile" aria-selected="false">Profile</button>
<button class="nav-link" id="nav-contact-tab" data-bs-toggle="tab" data-bs-target="#nav-contact" type="button" role="tab" aria-controls="nav-contact" aria-selected="false">Contact</button>
<button class="nav-link" id="nav-disabled-tab" data-bs-toggle="tab" data-bs-target="#nav-disabled" type="button" role="tab" aria-controls="nav-disabled" aria-selected="false" disabled>Disabled</button>
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="nav-contact" role="tabpanel" aria-labelledby="nav-contact-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="nav-disabled" role="tabpanel" aria-labelledby="nav-disabled-tab" tabindex="0">...</div>
</div>
Salgylar plugin hem dermanlar bilen işleýär.
Bu, Öý goýmasynyň baglanyşykly mazmuny. Başga bir düwmä bassaňyz, indiki üçin görnükliligini üýtgeder. JavaScript goýmasy, mazmunyň görünmegine we stiline gözegçilik etmek üçin sapaklary çalyşýar. Salgylar, dermanlar we beýleki .nav
güýçli nawigasiýa bilen ulanyp bilersiňiz.
This is some placeholder content the Profile tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav
-powered navigation.
This is some placeholder content the Contact tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav
-powered navigation.
This is some placeholder content the Disabled tab's associated content.
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="pills-home-tab" data-bs-toggle="pill" data-bs-target="#pills-home" type="button" role="tab" aria-controls="pills-home" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-profile-tab" data-bs-toggle="pill" data-bs-target="#pills-profile" type="button" role="tab" aria-controls="pills-profile" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-contact-tab" data-bs-toggle="pill" data-bs-target="#pills-contact" type="button" role="tab" aria-controls="pills-contact" aria-selected="false">Contact</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-disabled-tab" data-bs-toggle="pill" data-bs-target="#pills-disabled" type="button" role="tab" aria-controls="pills-disabled" aria-selected="false" disabled>Disabled</button>
</li>
</ul>
<div class="tab-content" id="pills-tabContent">
<div class="tab-pane fade show active" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="pills-disabled" role="tabpanel" aria-labelledby="pills-disabled-tab" tabindex="0">...</div>
</div>
Wertikal dermanlar bilen. aria-orientation="vertical"
Iň gowusy, wertikal bellikler üçin, tablisa sanawynyň konteýnerine hem goşmaly .
Bu, Öý goýmasynyň baglanyşykly mazmuny. Başga bir düwmä bassaňyz, indiki üçin görnükliligini üýtgeder. JavaScript goýmasy, mazmunyň görünmegine we stiline gözegçilik etmek üçin sapaklary çalyşýar. Salgylar, dermanlar we beýleki .nav
güýçli nawigasiýa bilen ulanyp bilersiňiz.
This is some placeholder content the Profile tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav
-powered navigation.
This is some placeholder content the Disabled tab's associated content.
This is some placeholder content the Messages tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav
-powered navigation.
This is some placeholder content the Settings tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav
-powered navigation.
<div class="d-flex align-items-start">
<div class="nav flex-column nav-pills me-3" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<button class="nav-link active" id="v-pills-home-tab" data-bs-toggle="pill" data-bs-target="#v-pills-home" type="button" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</button>
<button class="nav-link" id="v-pills-profile-tab" data-bs-toggle="pill" data-bs-target="#v-pills-profile" type="button" role="tab" aria-controls="v-pills-profile" aria-selected="false">Profile</button>
<button class="nav-link" id="v-pills-disabled-tab" data-bs-toggle="pill" data-bs-target="#v-pills-disabled" type="button" role="tab" aria-controls="v-pills-disabled" aria-selected="false" disabled>Disabled</button>
<button class="nav-link" id="v-pills-messages-tab" data-bs-toggle="pill" data-bs-target="#v-pills-messages" type="button" role="tab" aria-controls="v-pills-messages" aria-selected="false">Messages</button>
<button class="nav-link" id="v-pills-settings-tab" data-bs-toggle="pill" data-bs-target="#v-pills-settings" type="button" role="tab" aria-controls="v-pills-settings" aria-selected="false">Settings</button>
</div>
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="v-pills-disabled" role="tabpanel" aria-labelledby="v-pills-disabled-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="v-pills-messages" role="tabpanel" aria-labelledby="v-pills-messages-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="v-pills-settings" role="tabpanel" aria-labelledby="v-pills-settings-tab" tabindex="0">...</div>
</div>
</div>
Elýeterlilik
ARIA Awtorlaşdyryş Amallary Gollanmasy tablisalarynda görkezilişi ýaly dinamiki bellikli interfeýsler, gurluşlaryny, işleýşini we häzirki ýagdaýyny kömekçi tehnologiýalary ulanyjylara (ekran okyjylary ýaly) ýetirmek üçin zerur we goşmaça atributlary talap edýär role="tablist"
. Iň oňat tejribe hökmünde, bellikler üçin elementleri ulanmagy maslahat berýäris , sebäbi bular täze sahypa ýa-da ýerleşişe däl-de, dinamiki üýtgeşmä itergi berýän dolandyryşlardyr.role="tab"
role="tabpanel"
aria-
<button>
ARIA Awtorlaşdyryş amallary nagşyna laýyklykda diňe häzirki işjeň goýma klawiatura fokusyny alýar. JavaScript plugin işe girizilende tabindex="-1"
, ähli hereketsiz goýma dolandyryşlarynda gurlar. Häzirki işjeň goýmanyň ünsi jemlenenden soň, kursor düwmeleri öňki / indiki goýmany işjeňleşdirýär we plugin şoňa görä herekettabindex
edýär . Şeýle-de bolsa, kursoryň esasy özara täsirleri barada aýdylanda, JavaScript plugininiň keseligine we dikligine tablisa sanawlaryny tapawutlandyrmaýandygyny belläň: tab sanawynyň ugruna garamazdan, ýokarky we çep kursor öňki tablisa, aşak we sag kursor gidýär. indiki goýma.
tabindex="0"
.
Maglumat atributlaryny ulanmak
data-bs-toggle="tab"
Diňe bir elementi ýa-da bir elementi görkezip, hiç hili JavaScript ýazmazdan, tab ýa-da tablet nawigasiýasyny işjeňleşdirip bilersiňiz data-bs-toggle="pill"
. Bu maglumat atributlaryny ulanyň ýa- .nav-tabs
da .nav-pills
.
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="messages-tab" data-bs-toggle="tab" data-bs-target="#messages" type="button" role="tab" aria-controls="messages" aria-selected="false">Messages</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="settings-tab" data-bs-toggle="tab" data-bs-target="#settings" type="button" role="tab" aria-controls="settings" aria-selected="false">Settings</button>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="home" role="tabpanel" aria-labelledby="home-tab" tabindex="0">...</div>
<div class="tab-pane" id="profile" role="tabpanel" aria-labelledby="profile-tab" tabindex="0">...</div>
<div class="tab-pane" id="messages" role="tabpanel" aria-labelledby="messages-tab" tabindex="0">...</div>
<div class="tab-pane" id="settings" role="tabpanel" aria-labelledby="settings-tab" tabindex="0">...</div>
</div>
JavaScript arkaly
JavaScript arkaly tablisa tablisalaryny açyň (her tab aýratynlykda işjeňleşdirilmeli):
const triggerTabList = document.querySelectorAll('#myTab button')
triggerTabList.forEach(triggerEl => {
const tabTrigger = new bootstrap.Tab(triggerEl)
triggerEl.addEventListener('click', event => {
event.preventDefault()
tabTrigger.show()
})
})
Aýry-aýry bellikleri birnäçe usul bilen işjeňleşdirip bilersiňiz:
const triggerEl = document.querySelector('#myTab button[data-bs-target="#profile"]')
bootstrap.Tab.getInstance(triggerEl).show() // Select tab by name
const triggerFirstTabEl = document.querySelector('#myTab li:first-child button')
bootstrap.Tab.getInstance(triggerFirstTabEl).show() // Select first tab
Öçürilen effekt
Salgylaryň ýitmegi .fade
üçin hersine goşuň .tab-pane
. Ilkinji goýma paneli .show
başlangyç mazmuny görünmeli.
<div class="tab-content">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="messages" role="tabpanel" aria-labelledby="messages-tab" tabindex="0">...</div>
<div class="tab-pane fade" id="settings" role="tabpanel" aria-labelledby="settings-tab" tabindex="0">...</div>
</div>
Usullar
Asynkron usullar we geçişler
APIhli API usullary asynkron bolup, geçişe başlaýar . Geçiş başlan badyna, ýöne gutarmanka jaň edijä gaýdyp gelýärler . Mundan başga-da, geçiş komponentine çagyryş usuly hasaba alynmaz .
Has giňişleýin maglumat üçin JavaScript resminamalarymyza serediň .
Mazmunyňyzy goýma elementi hökmünde işjeňleşdirýär.
Konstruktor bilen bir tab mysal döredip bilersiňiz, mysal üçin:
const bsTab = new bootstrap.Tab('#myTab')
Usul | Düşündiriş |
---|---|
dispose |
Bir elementiň goýmasyny ýok edýär. |
getInstance |
DOM elementi bilen baglanyşykly tab mysalyny almaga mümkinçilik berýän statiki usul, ony şeýle ulanyp bilersiňiz : bootstrap.Tab.getInstance(element) . |
getOrCreateInstance |
DOM elementi bilen baglanyşykly tablisa mysalyny yzyna gaýtaryp berýän ýa-da başlamadyk ýagdaýynda täzesini döredýän statiki usul. Muny şeýle ulanyp bilersiňiz : bootstrap.Tab.getOrCreateInstance(element) . |
show |
Berlen goýmany saýlaýar we baglanyşykly paneli görkezýär. Öň saýlanan başga bir tab saýlanmaýar we oňa bagly panel gizlenýär. Salgy paneli hakykatdanam görkezilmänkä (ýagny shown.bs.tab waka ýüze çykmazdan ozal) jaň edijä gaýdyp gelýär. |
Wakalar
Täze tab görkezilende wakalar aşakdaky tertipde ýanýar:
hide.bs.tab
(häzirki işjeň goýmada)show.bs.tab
(görkezilmeli goýmada)hidden.bs.tab
hide.bs.tab
(öňki işjeň goýmada, waka bilen birmeňzeş )shown.bs.tab
show.bs.tab
(täze işjeň görkezilen ýaňy görkezilen goýmada, waka bilen birmeňzeş )
Hiç bir goýma eýýäm işjeň bolmadyk bolsa, wakalar hide.bs.tab
we hidden.bs.tab
wakalar atylmaz.
Çäräniň görnüşi | Düşündiriş |
---|---|
hide.bs.tab |
Bu waka täze goýma görkezilmeli bolanda ýanýar (we şeýlelik bilen öňki işjeň goýma gizlenmeli). Häzirki işjeň goýmany we ýakyn wagtda işjeň boljak täze goýmany ulanyň event.target we nyşana alyň.event.relatedTarget |
hidden.bs.tab |
Bu waka täze goýma görkezilenden soň ýanýar (we şeýlelik bilen öňki işjeň goýma gizlenýär). Öňki işjeň goýmany we täze işjeň goýmany degişlilikde ulanyň event.target we nyşana alyň.event.relatedTarget |
show.bs.tab |
Bu waka tab goýmasynda ýanýar, ýöne täze goýma görkezilmänkä. Işjeň goýmany we öňki işjeň goýmany degişlilikde ulanyň event.target we nyşana alyň.event.relatedTarget |
shown.bs.tab |
Bu waka, görkezme görkezilenden soň tab goýmasynda ýanýar. Işjeň goýmany we öňki işjeň goýmany degişlilikde ulanyň event.target we nyşana alyň.event.relatedTarget |
const tabEl = document.querySelector('button[data-bs-toggle="tab"]')
tabEl.addEventListener('shown.bs.tab', event => {
event.target // newly activated tab
event.relatedTarget // previous active tab
})