Deňiz güýçleri
“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.
.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.
<ul class="nav">
<li class="nav-item">
<a class="nav-link active" 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. <ul>
Harytlaryňyzyň tertibi möhüm bolsa, ýokardaky ýaly s ulanyň <ol>
ýa-da <nav>
element bilen özüňizi aýlaň. .nav
Ulanylyşy sebäpli display: flex
, nav baglanyşyklary nav elementleri ýaly hereket edýär, ýöne goşmaça bellik bolmazdan.
<nav class="nav">
<a class="nav-link active" 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" 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" 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, beýlekilerde 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" 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" 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" 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" 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" 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" 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" 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" 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" 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ç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" href="#">Active</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">Dropdown</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Separated link</a>
</div>
</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" href="#">Active</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">Dropdown</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Separated link</a>
</div>
</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>
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ň.
JavaScriptimizi çeşmeden gurýan bolsaňyz, talap edýärutil.js
.
ARIA Awtorlaşdyryş Amallary Gollanmasy tablisalarynda görkezilişi ýaly dinamiki tablisa interfeýsleri, kömekçi tehnologiýalary ulanyjylara (ekran okyjylary ýaly) gurluşyny , işleýşini we häzirki ýagdaýyny ý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>
Salgy paneli üçin ýer eýesi mazmuny. Bu, öý goýmasy bilen baglanyşykly. Seni beýiklige, şeýle beýiklige çykarýar, sebäbi ol şol bir halkara ýylgyryşyna eýe boldy. Bedatan ýerimde nätanyş bir adam bar, kellämde bir zat bar. Ay Ýok. Başga bir durmuşda seni galmaga mejbur ederdim. 'Sebäbi men, islendik zada ukyply. Täç söweşime taýýar. Ene-ataňyzyň içgisini ogurlamak we üçege çykmak üçin ulanylýar. Saz, sazlaşykly we taýýar, ony açyň, gettiniň agyr bolmagyna sebäp bolýar. Söýgüsi neşe ýalydyr. Saýlawymy ýatdan çykardym öýdýän.
Salgy paneli üçin ýer eýesi mazmuny. Bu, profil goýmasyna degişlidir. Iň oňat arhitektura aldyňyz. Pasport markalary, ol kosmopolit. Gowy, täze, gazaply, biz ony gulpladyk. Hiç haçan bir gün seni ýitirjekdigimi meýilleşdirmedim. Yourüregiňizi iýýär. Öpüşiňiz kosmiki, her hereket jadyly. Olary göz öňünde tutýaryn, edil özi ýaly. Salam ýakynlar bilen salamlaşalyň. Diňe 4-nji iýul ýaly gijä eýe boluň! Youöne isrip bolmagyňyzy isleýärsiňiz.
Placeholder content for the tab panel. This one relates to the contact tab. Her love is like a drug. All my girls vintage Chanel baby. Got a motel and built a fort out of sheets. 'Cause she's the muse and the artist. (This is how we do) So you wanna play with magic. So just be sure before you give it all to me. I'm walking, I'm walking on air (tonight). Skip the talk, heard it all, time to walk the walk. Catch her if you can. Stinging like a bee I earned my stripes.
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-toggle="tab" data-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-toggle="tab" data-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="contact-tab" data-toggle="tab" data-target="#contact" type="button" role="tab" aria-controls="contact" aria-selected="false">Contact</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">...</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-toggle="tab" data-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-toggle="tab" data-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-toggle="tab" data-target="#nav-contact" type="button" role="tab" aria-controls="nav-contact" aria-selected="false">Contact</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">...</div>
<div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">...</div>
<div class="tab-pane fade" id="nav-contact" role="tabpanel" aria-labelledby="nav-contact-tab">...</div>
</div>
Salgylar plugin hem dermanlar bilen işleýär.
Salgy paneli üçin ýer eýesi mazmuny. Bu, öý goýmasy bilen baglanyşykly. Seni beýiklige, şeýle beýiklige çykarýar, sebäbi ol şol bir halkara ýylgyryşyna eýe boldy. Bedatan ýerimde nätanyş bir adam bar, kellämde bir zat bar. Ay Ýok. Başga bir durmuşda seni galmaga mejbur ederdim. 'Sebäbi men, islendik zada ukyply. Täç söweşime taýýar. Ene-ataňyzyň içgisini ogurlamak we üçege çykmak üçin ulanylýar. Saz, sazlaşykly we taýýar, ony açyň, gettiniň agyr bolmagyna sebäp bolýar. Söýgüsi neşe ýalydyr. Saýlawymy ýatdan çykardym öýdýän.
Placeholder content for the tab panel. This one relates to the profile tab. You got the finest architecture. Passport stamps, she's cosmopolitan. Fine, fresh, fierce, we got it on lock. Never planned that one day I'd be losing you. She eats your heart out. Your kiss is cosmic, every move is magic. I mean the ones, I mean like she's the one. Greetings loved ones let's take a journey. Just own the night like the 4th of July! But you'd rather get wasted.
Placeholder content for the tab panel. This one relates to the contact tab. Her love is like a drug. All my girls vintage Chanel baby. Got a motel and built a fort out of sheets. 'Cause she's the muse and the artist. (This is how we do) So you wanna play with magic. So just be sure before you give it all to me. I'm walking, I'm walking on air (tonight). Skip the talk, heard it all, time to walk the walk. Catch her if you can. Stinging like a bee I earned my stripes.
<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-toggle="pill" data-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-toggle="pill" data-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-toggle="pill" data-target="#pills-contact" type="button" role="tab" aria-controls="pills-contact" aria-selected="false">Contact</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">...</div>
<div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">...</div>
<div class="tab-pane fade" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab">...</div>
</div>
Wertikal dermanlar bilen.
Salgy paneli üçin ýer eýesi mazmuny. Bu, öý goýmasy bilen baglanyşykly. Şäheriň merkezinde “Blues” aýdymyny gördüm. Zeýkeşiň töweregine tomaşa ediň. Näme üçin meni saklamaga rugsat bermeýärsiň? Agyr täji geýýän kelledir. Hawa, ýokardan ýokardan ýagyş ýagyp, perişdeleri aglaýarys. Görkezişi 3D görnüşinde görmek isleýärin. Hiç wagt duýmaýarsyňyzmy, gaty kagyz duýýarsyňyzmy? Hawa ýa-da ýok, mümkin ýok.
Placeholder content for the tab panel. This one relates to the profile tab. Takes you miles high, so high, 'cause she’s got that one international smile. There's a stranger in my bed, there's a pounding in my head. Oh, no. In another life I would make you stay. ‘Cause I, I’m capable of anything. Suiting up for my crowning battle. Used to steal your parents' liquor and climb to the roof. Tone, tan fit and ready, turn it up cause its gettin' heavy. Her love is like a drug. I guess that I forgot I had a choice.
Placeholder content for the tab panel. This one relates to the messages tab. You got the finest architecture. Passport stamps, she's cosmopolitan. Fine, fresh, fierce, we got it on lock. Never planned that one day I'd be losing you. She eats your heart out. Your kiss is cosmic, every move is magic. I mean the ones, I mean like she's the one. Greetings loved ones let's take a journey. Just own the night like the 4th of July! But you'd rather get wasted.
Placeholder content for the tab panel. This one relates to the settings tab. Her love is like a drug. All my girls vintage Chanel baby. Got a motel and built a fort out of sheets. 'Cause she's the muse and the artist. (This is how we do) So you wanna play with magic. So just be sure before you give it all to me. I'm walking, I'm walking on air (tonight). Skip the talk, heard it all, time to walk the walk. Catch her if you can. Stinging like a bee I earned my stripes.
<div class="row">
<div class="col-3">
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<button class="nav-link active" id="v-pills-home-tab" data-toggle="pill" data-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-toggle="pill" data-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-messages-tab" data-toggle="pill" data-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-toggle="pill" data-target="#v-pills-settings" type="button" role="tab" aria-controls="v-pills-settings" aria-selected="false">Settings</button>
</div>
</div>
<div class="col-9">
<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">...</div>
<div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab">...</div>
<div class="tab-pane fade" id="v-pills-messages" role="tabpanel" aria-labelledby="v-pills-messages-tab">...</div>
<div class="tab-pane fade" id="v-pills-settings" role="tabpanel" aria-labelledby="v-pills-settings-tab">...</div>
</div>
</div>
</div>
Maglumat atributlaryny ulanmak
data-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-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-toggle="tab" data-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-toggle="tab" data-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-toggle="tab" data-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-toggle="tab" data-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">...</div>
<div class="tab-pane" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane" id="messages" role="tabpanel" aria-labelledby="messages-tab">...</div>
<div class="tab-pane" id="settings" role="tabpanel" aria-labelledby="settings-tab">...</div>
</div>
JavaScript arkaly
JavaScript arkaly tablisa tablisalaryny açyň (her tab aýratynlykda işjeňleşdirilmeli):
$('#myTab button').on('click', function (event) {
event.preventDefault()
$(this).tab('show')
})
Aýry-aýry bellikleri birnäçe usul bilen işjeňleşdirip bilersiňiz:
$('#myTab button[data-target="#profile"]').tab('show') // Select tab by name
$('#myTab li:first-child button').tab('show') // Select first tab
$('#myTab li:last-child button').tab('show') // Select last tab
$('#myTab li:nth-child(3) button').tab('show') // Select third 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">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane fade" id="messages" role="tabpanel" aria-labelledby="messages-tab">...</div>
<div class="tab-pane fade" id="settings" role="tabpanel" aria-labelledby="settings-tab">...</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ň .
$ () goýmasy
Salgy elementini we mazmun gapyny işjeňleşdirýär. Salgyda ýa- data-target
da bir baglanyşyk ulanýan bolsa href
, DOM-da konteýner düwünini nyşana alýan atribut bolmaly.
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-toggle="tab" data-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-toggle="tab" data-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-toggle="tab" data-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-toggle="tab" data-target="#settings" type="button" role="tab" aria-controls="settings" aria-selected="false">Settings</button>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
<div class="tab-pane" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane" id="messages" role="tabpanel" aria-labelledby="messages-tab">...</div>
<div class="tab-pane" id="settings" role="tabpanel" aria-labelledby="settings-tab">...</div>
</div>
<script>
$(function () {
$('#myTab li:last-child button').tab('show')
})
</script>
.tab ('görkezmek')
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.
$('#someTab').tab('show')
.tab ('ýok etmek')
Bir elementiň goýmasyny ýok edýä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 tab goýmasy işjeň bolmadyk bolsa, wakalar hide.bs.tab
we hidden.bs.tab
wakalar atylmaz.
Çäräniň görnüşi | Düşündiriş |
---|---|
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 |
görkezilen.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 |
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 |
gizlenen.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 |
$('button[data-toggle="tab"]').on('shown.bs.tab', function (event) {
event.target // newly activated tab
event.relatedTarget // previous active tab
})