Navbar
Bootstrap-yň güýçli, täsirli nawigasiýa sözbaşy, deňiz paneli üçin resminamalar we mysallar. Marka, nawigasiýa we ş.m. goldawy, şol sanda ýykylýan pluginimize goldawy öz içine alýar.
Deňiz paneli bilen başlamazdan ozal bilmeli zatlaryňyz:
- Gämi duralgalary täsirli çökmek we reňk shemasy sapaklary üçin
.navbar
örtük talap edýär ..navbar-expand{-sm|-md|-lg|-xl}
- Gämi duralgalary we olaryň mazmuny adaty ýagdaýda suwukdyr. Gorizontal giňligini çäklendirmek üçin goşmaça gaplary ulanyň .
- Deňiz panelleriniň arasyndaky aralygy we deňleşmegi dolandyrmak üçin aralyk we flex peýdaly synplarymyzy ulanyň .
- Gämi duralgalary adaty ýagdaýda jogap berýär, ýöne muny üýtgetmek üçin aňsatlyk bilen üýtgedip bilersiňiz. Jogapkärçilikli hereket, “Collapse JavaScript” pluginimize baglydyr.
- Gämi duralgalary çap edilende asyl görnüşde gizlenýär. Goşmak arkaly olary çap
.d-print
etmäge mejbur ediň.navbar
. Ekranyň peýdaly synpyna serediň . - Bir elementi ulanyp, elýeterliligi üpjün ediň
<nav>
ýa-da a ýaly has umumy elementi ulanýan bolsaňyz , kömekçi tehnologiýalary ulanýanlar üçin möhüm sebit hökmünde aç-açan kesgitlemek üçin her bir deňiz paneline<div>
bir goşuň .role="navigation"
Mysal we goldanýan kiçi komponentleriň sanawyny okaň.
Gämi duralgalary az sanly bölekler üçin içerki goldaw bilen gelýär. Zerur bolanda aşakdakylardan saýlaň:
.navbar-brand
kompaniýaňyz, önümiňiz ýa-da taslama adyňyz üçin..navbar-nav
doly beýik we ýeňil nawigasiýa üçin (aşak düşýänlere goldaw goşmak bilen)..navbar-toggler
ýykylýan pluginimiz we beýleki nawigasiýa hereketlerini üýtgetmek üçin ulanmak üçin..form-inline
islendik görnüşdäki gözegçilik we hereketler üçin..navbar-text
dikligine merkezleşdirilen tekstleri goşmak üçin..collapse.navbar-collapse
ene-atanyň nokady boýunça navbar mazmunyny toparlaşdyrmak we gizlemek üçin.
lg
Ine, (uly) kesiş nokadynda awtomatiki ýykylýan täsirli ýagtylyk temaly deňiz paneline girizilen ähli kiçi komponentleriň mysaly .
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
Bu mysalda reňk ( bg-light
) we aralyk ( my-2
,,, ) my-lg-0
peýdaly synplar ulanylýar mr-sm-0
.my-sm-0
Bu .navbar-brand
element köp elementlere ulanylyp bilner, ýöne labyr iň oňat işleýär, sebäbi käbir elementler peýdaly synplary ýa-da adaty stilleri talap edip biler.
<!-- As a link -->
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
</nav>
<!-- As a heading -->
<nav class="navbar navbar-light bg-light">
<span class="navbar-brand mb-0 h1">Navbar</span>
</nav>
Şekilleri islege goşmak, .navbar-brand
elmydama dogry ölçeg üçin adaty stilleri ýa-da kömekçi enjamlary talap eder. Ine görkezmek üçin käbir mysallar.
<!-- Just an image -->
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#">
<img src="/docs/4.0/assets/brand/bootstrap-solid.svg" width="30" height="30" alt="">
</a>
</nav>
<!-- Image and text -->
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#">
<img src="/docs/4.0/assets/brand/bootstrap-solid.svg" width="30" height="30" class="d-inline-block align-top" alt="">
Bootstrap
</a>
</nav>
Navbar nawigasiýa baglanyşyklary .nav
, öz üýtgediji synpy bilen opsiýalarymyzda gurulýar we dogry jogap bermek üçin açyk synplary ulanmagy talap edýär. Deňiz panellerinde nawigasiýa, deňiz paneliňiziň mazmunyny ygtybarly sazlamak üçin mümkin boldugyça gorizontal giňişligi eýelemek üçin öser .
Işjeň ýagdaýlar , häzirki sahypany göni ýa-da ýakyn ene-atalaryna .active
ulanyp boljakdygyny görkezmek üçin ..nav-link
.nav-item
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
Deňiz güýçlerimiz üçin sapaklary ulanýandygymyz sebäpli, isleseňiz sanaw esasly çemeleşmeden doly gaçyp bilersiňiz.
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#">Features</a>
<a class="nav-item nav-link" href="#">Pricing</a>
<a class="nav-item nav-link disabled" href="#">Disabled</a>
</div>
</div>
</nav>
Şeýle hem, deňiz paneliňizdäki açylan ýerleri ulanyp bilersiňiz. Açylýan menýular ýerleşdirmek üçin örtük elementini talap edýär, şonuň üçin aşakda görkezilişi ýaly aýratyn .nav-item
we ýerleşdirilen elementleri ulanmagy unutmaň..nav-link
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown link
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<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>
</li>
</ul>
</div>
</nav>
Dürli forma dolandyryşlaryny we böleklerini deňiz panelinde ýerleşdiriň .form-inline
.
<nav class="navbar navbar-light bg-light">
<form class="form-inline">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</nav>
Içerki görnüşleriňiziň mazmunyny zerurlyk bilen kommunal hyzmatlar bilen deňleşdiriň.
<nav class="navbar navbar-light bg-light justify-content-between">
<a class="navbar-brand">Navbar</a>
<form class="form-inline">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</nav>
Giriş toparlary hem işleýär:
<nav class="navbar navbar-light bg-light">
<form class="form-inline">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">@</span>
</div>
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
</div>
</form>
</nav>
Bu düwme görnüşleriniň bir bölegi hökmünde dürli düwmeler hem goldanýar. Bu, wertikal deňleşdiriş enjamlarynyň dürli ululykdaky elementleri deňleşdirmek üçin ulanylyp bilinjekdigini hem ýatladýar.
<nav class="navbar navbar-light bg-light">
<form class="form-inline">
<button class="btn btn-outline-success" type="button">Main button</button>
<button class="btn btn-sm btn-outline-secondary" type="button">Smaller button</button>
</form>
</nav>
Gämi duralgalarynyň kömegi bilen bir topar tekst bolup biler .navbar-text
. Bu synp tekstiň setirleri üçin dik tekizlemäni we keseligine aralygy sazlaýar.
<nav class="navbar navbar-light bg-light">
<span class="navbar-text">
Navbar text with an inline element
</span>
</nav>
Zerur bolanda beýleki komponentler we kömekçi enjamlar bilen garyşdyryň we gabat geliň.
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar w/ text</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
<span class="navbar-text">
Navbar text with an inline element
</span>
</div>
</nav>
Deňiz panelini ýylatmak, mowzuk sapaklarynyň we kömekçi enjamlaryň utgaşmasy netijesinde hiç haçan aňsat bolmady background-color
. .navbar-light
Açyk fon reňkleri ýa-da goýy fon reňkleri üçin saýlaň .navbar-dark
. Soň bolsa, .bg-*
kömekçi enjamlar bilen sazlaň.
Gerek däl bolsa-da, bir sahypany merkezleşdirmek üçin bir çyzgy paneli bilen örtüp ýa-da diňe kesgitli ýa-da statiki ýokarky deňiz paneliniň.container
mazmunyny merkezleşdirmek üçin birine goşup bilersiňiz .
<div class="container">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
</nav>
</div>
.navbar-expand{-sm|-md|-lg|-xl}
Konteýner deňiz paneliňizde bolsa, gorizontal padding görkezilen synpyňyzdan pes nokatlarda aýrylýar . Deňiz paneli ýykylanda aşaky görnüşdäki ýerlere gereksiz ýerleşdirmekligi iki esse artdyrmaýarys.
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="#">Navbar</a>
</div>
</nav>
Deňiz panellerini statik däl ýerlerde ýerleşdirmek üçin pozisiýa hyzmatlarymyzy ulanyň . Fixedokardan ýokarsyna, aşagyna berkidilen ýa-da ýokarsyna berkidilenini saýlaň (sahypa ýokarsyna ýetýänçä aýlaň, soňra şol ýerde galar). Kesgitli gämi duralgalary ulanylýar position: fixed
, ýagny DOM-yň adaty akymyndan çekilýär we beýleki elementler bilen gabat gelmezligi üçin ýörite CSS talap edip biler (mysal padding-top
üçin ).<body>
Şeýle hem , her brauzerde doly goldanmaýan.sticky-top
ulanylyşynaposition: sticky
üns beriň .
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#">Default</a>
</nav>
<nav class="navbar fixed-top navbar-light bg-light">
<a class="navbar-brand" href="#">Fixed top</a>
</nav>
<nav class="navbar fixed-bottom navbar-light bg-light">
<a class="navbar-brand" href="#">Fixed bottom</a>
</nav>
<nav class="navbar sticky-top navbar-light bg-light">
<a class="navbar-brand" href="#">Sticky top</a>
</nav>
Navbars mazmuny bir düwmäniň .navbar-toggler
aňyrsynda ýykylanda üýtgäp biler. Beýleki kömekçi enjamlar bilen bilelikde belli elementleri haçan görkezmelidigini ýa-da gizlemelidigini aňsatlyk bilen saýlap bilersiňiz..navbar-collapse
.navbar-expand{-sm|-md|-lg|-xl}
Hiç haçan ýykylmaýan gämi duralgalary üçin, deňiz paneline .navbar-expand
synp goşuň. Elmydama ýykylýan gämi duralgalary üçin hiç hili .navbar-expand
synp goşmaň.
Navbar açarlary, adaty ýagdaýda çep hatara düzülendir, ýöne a ýaly dogan elementine eýerseler, .navbar-brand
awtomatiki usulda sag tarapa deňleşerler. Belgiňizi yzyna öwürmek, geçirijiniň ýerleşdirilmegini tersleşdirer. Aşakda dürli üýtgetmek stilleriniň mysallary getirilýär.
Iň .navbar-brand
pes nokatda görkezilmedik:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a class="navbar-brand" href="#">Hidden brand</a>
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
Çepde görkezilen marka ady we sag tarapda üýtgetmek:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo02">
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
Çepde açar we sagda marka ady bilen:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar</a>
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
Käwagt sahypanyň başga bir ýerinde gizlin mazmuny döretmek üçin çökmek plaginini ulanmak isleýärsiňiz. Plaginimiz gabat gelýän id
we data-target
işleýänligi sebäpli, aňsatlyk bilen ýerine ýetirilýär!
<div class="pos-f-t">
<div class="collapse" id="navbarToggleExternalContent">
<div class="bg-dark p-4">
<h4 class="text-white">Collapsed content</h4>
<span class="text-muted">Toggleable via the navbar brand.</span>
</div>
</div>
<nav class="navbar navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</nav>
</div>