Esasy mazmuna geçiň Docs nawigasiýasyna geçiň
in English

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.

Bu nähili işleýär

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|-xxl}
  • Gämi duralgalary we olaryň mazmuny adaty ýagdaýda suwukdyr. Gorizontal giňligini dürli usullar bilen çäklendirmek üçin gapy üýtgediň .
  • 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.
  • 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>goşuň .role="navigation"
  • aria-current="page"Häzirki sahypany ýa aria-current="true"-da toplumdaky häzirki elementi ulanyp, häzirki elementi görkeziň .
Bu komponentiň animasiýa täsiri prefers-reduced-motionmedia talaplaryna baglydyr. Elýeterlilik resminamalarymyzyň azaldylan hereket bölümine serediň .

Goldanýan mazmun

Gämi duralgalary az sanly kiçi komponentler üçin içerki goldaw bilen gelýär. Zerur bolanda aşakdakylardan saýlaň:

  • .navbar-brandkompaniýaňyz, önümiňiz ýa-da taslama adyňyz üçin.
  • .navbar-navdoly 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.
  • Islendik görnüşdäki dolandyryş we hereketler üçin çeýe we aralyk enjamlary.
  • .navbar-textdikligine merkezleşdirilen tekstleri goşmak üçin.
  • .collapse.navbar-collapseene-atanyň nokady boýunça navbar mazmunyny toparlaşdyrmak we gizlemek üçin.
  • Giňeldilen navbar mazmunyny.navbar-scroll düzmek max-heightwe aýlamak üçin islege bagly goşuň .

lgIne, (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">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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 me-auto mb-2 mb-lg-0">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</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-bs-toggle="dropdown" aria-expanded="false">
            Dropdown
          </a>
          <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
            <li><a class="dropdown-item" href="#">Action</a></li>
            <li><a class="dropdown-item" href="#">Another action</a></li>
            <li><hr class="dropdown-divider"></li>
            <li><a class="dropdown-item" href="#">Something else here</a></li>
          </ul>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
        </li>
      </ul>
      <form class="d-flex">
        <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
        <button class="btn btn-outline-success" type="submit">Search</button>
      </form>
    </div>
  </div>
</nav>

Bu mysalda fon ( bg-light) we aralyk ( my-2,,, ) my-lg-0peýdaly synplar ulanylýar me-sm-0.my-sm-0

Marka

Bu .navbar-brandelement 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.

Tekst

Tekstiňizi .navbar-brandsynp bilen bir elementiň içine goşuň.

<!-- As a link -->
<nav class="navbar navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Navbar</a>
  </div>
</nav>

<!-- As a heading -->
<nav class="navbar navbar-light bg-light">
  <div class="container-fluid">
    <span class="navbar-brand mb-0 h1">Navbar</span>
  </div>
</nav>

Surat

Tekstiň içindäki teksti .navbar-brandan bilen çalşyp bilersiňiz <img>.

<nav class="navbar navbar-light bg-light">
  <div class="container">
    <a class="navbar-brand" href="#">
      <img src="/docs/5.0/assets/brand/bootstrap-logo.svg" alt="" width="30" height="24">
    </a>
  </div>
</nav>

Surat we tekst

Şol bir wagtyň özünde surat we tekst goşmak üçin käbir goşmaça enjamlardan peýdalanyp bilersiňiz. Goşulmagyna .d-inline-blockwe .align-text-topüstünde belläň <img>.

<nav class="navbar navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">
      <img src="/docs/5.0/assets/brand/bootstrap-logo.svg" alt="" width="30" height="24" class="d-inline-block align-text-top">
      Bootstrap
    </a>
  </div>
</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 panellerindäki nawigasiýa, deňiz paneliňiziň mazmunyny ygtybarly sazlamak üçin mümkin boldugyça gorizontal giňişligi eýeleýär .

Häzirki sahypany görkezmek üçin .activesynp goşuň ..nav-link

aria-currentAktiwlere atribut goşmalydygyny ýadyňyzdan çykarmaň .nav-link.

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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">
          <a class="nav-link active" aria-current="page" href="#">Home</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="#" tabindex="-1" aria-disabled="true">Disabled</a>
        </li>
      </ul>
    </div>
  </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">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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-link active" aria-current="page" href="#">Home</a>
        <a class="nav-link" href="#">Features</a>
        <a class="nav-link" href="#">Pricing</a>
        <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
      </div>
    </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-itemwe ýerleşdirilen elementleri ulanmagy unutmaň..nav-link

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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">
          <a class="nav-link active" aria-current="page" href="#">Home</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" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            Dropdown link
          </a>
          <ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
            <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>
          </ul>
        </li>
      </ul>
    </div>
  </div>
</nav>

Formalar

Dürli görnüş dolandyryşlaryny we böleklerini deňiz panelinde ýerleşdiriň:

<nav class="navbar navbar-light bg-light">
  <div class="container-fluid">
    <form class="d-flex">
      <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
      <button class="btn btn-outline-success" type="submit">Search</button>
    </form>
  </div>
</nav>

.navbarÇeýe düzülişiň derrew çaga elementleri we ýerine ýetiriler justify-content: space-between. Bu özüni alyp barşy sazlamak üçin zerur bolan goşmaça flex hyzmatlaryny ulanyň.

<nav class="navbar navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand">Navbar</a>
    <form class="d-flex">
      <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
      <button class="btn btn-outline-success" type="submit">Search</button>
    </form>
  </div>
</nav>

Giriş toparlary hem işleýär. Deňiz paneli tutuş bir görnüş bolsa ýa-da esasan bir görnüş bolsa, <form>elementi konteýner hökmünde ulanyp, HTML-ni ýatda saklap bilersiňiz.

<nav class="navbar navbar-light bg-light">
  <form class="container-fluid">
    <div class="input-group">
      <span class="input-group-text" id="basic-addon1">@</span>
      <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="container-fluid justify-content-start">
    <button class="btn btn-outline-success me-2" type="button">Main button</button>
    <button class="btn btn-sm btn-outline-secondary" type="button">Smaller button</button>
  </form>
</nav>

Tekst

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">
  <div class="container-fluid">
    <span class="navbar-text">
      Navbar text with an inline element
    </span>
  </div>
</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">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Navbar w/ text</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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 me-auto mb-2 mb-lg-0">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</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>
  </div>
</nav>

Reňk shemalary

Deňiz panelini gyzdyrmak, mowzuk sapaklarynyň we kömekçi enjamlaryň utgaşmasy netijesinde hiç haçan aňsat bolmady background-color. .navbar-lightAç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ň.

<nav class="navbar navbar-dark bg-dark">
  <!-- Navbar content -->
</nav>

<nav class="navbar navbar-dark bg-primary">
  <!-- Navbar content -->
</nav>

<nav class="navbar navbar-light" style="background-color: #e3f2fd;">
  <!-- Navbar content -->
</nav>

Konteýnerler

Gerek däl bolsa .container-da, bir sahypany merkezde jemlemek üçin deňiz paneli bilen örtüp bilersiňiz - içerki konteýneriň henizem zerurdygyny belläň. Ora-da diňe durnukly ýa-da statiki ýokarky gämi duralgasynyň.navbar mazmunyny merkezleşdirmek üçin bir konteýner goşup bilersiňiz .

<div class="container">
  <nav class="navbar navbar-expand-lg navbar-light bg-light">
    <div class="container-fluid">
      <a class="navbar-brand" href="#">Navbar</a>
    </div>
  </nav>
</div>

Deňiz paneliňizdäki mazmunyň näderejede giňdigini görkezmek üçin haýsydyr bir konteýner ulanyň.

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-md">
    <a class="navbar-brand" href="#">Navbar</a>
  </div>
</nav>

Acementerleşiş

Deňiz panellerini statik däl ýagdaýlara ý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 galyň). 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">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Default</a>
  </div>
</nav>
<nav class="navbar fixed-top navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Fixed top</a>
  </div>
</nav>
<nav class="navbar fixed-bottom navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Fixed bottom</a>
  </div>
</nav>
<nav class="navbar sticky-top navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Sticky top</a>
  </div>
</nav>

Aýlamak

.navbar-nav-scrollAykylan deňiz paneliniň üýtgäp bilýän mazmunynyň içinde dik aýlanmagy üpjün etmek üçin .navbar-nav(ýa-da beýleki deňiz paneli kiçi komponentine) goşuň . Düzgüne görä, aýlamak başlaýar 75vh(ýa-da görüniş beýikliginiň 75%), ýöne ýerli CSS adaty emläk --bs-navbar-heightýa-da adaty stil bilen ýok edip bilersiňiz. Deňiz paneli giňeldilende has uly görnüşlerde mazmun, adaty deňiz panelinde bolşy ýaly peýda bolar.

Bu özüni alyp barşyň potensial kemçilikleri bilen ýüze çykýandygyny ýadyňyzdan çykarmaň - overflowsazlamalar overflow-y: auto(mazmuny şu ýere aýlamak üçin zerur), gorizontal mazmuny kesjek overflow-xekwiwalentdir .auto

Ine, iň oňat aralyk üçin goşmaça margin enjamlary bilen .navbar-nav-scrollulanylýan navbar paneli.style="--bs-scroll-height: 100px;"

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Navbar scroll</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarScroll" aria-controls="navbarScroll" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarScroll">
      <ul class="navbar-nav me-auto my-2 my-lg-0 navbar-nav-scroll" style="--bs-scroll-height: 100px;">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</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="navbarScrollingDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            Link
          </a>
          <ul class="dropdown-menu" aria-labelledby="navbarScrollingDropdown">
            <li><a class="dropdown-item" href="#">Action</a></li>
            <li><a class="dropdown-item" href="#">Another action</a></li>
            <li><hr class="dropdown-divider"></li>
            <li><a class="dropdown-item" href="#">Something else here</a></li>
          </ul>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Link</a>
        </li>
      </ul>
      <form class="d-flex">
        <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
        <button class="btn btn-outline-success" type="submit">Search</button>
      </form>
    </div>
  </div>
</nav>

Jogapkärçilikli özüni alyp baryş

Gämi duralgalary mazmunynyň bir düwmäniň aňyrsynda haçan ýykylýandygyny kesgitlemek üçin .navbar-togglerulanyp bilerler . 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|-xxl}

Hiç haçan ýykylmaýan gämi duralgalary üçin, deňiz paneline .navbar-expandsynp goşuň. Elmydama ýykylýan gämi duralgalary üçin hiç hili .navbar-expandsynp goşmaň.

Toggler

Navbar açarlary, adaty ýagdaýda çep hatara düzülendir, ýöne a ýaly dogan elementine eýerseler, .navbar-brandawtomatiki 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.

.navbar-brandkiçi nokatda görkezilmedi:

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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 me-auto mb-2 mb-lg-0">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
        </li>
      </ul>
      <form class="d-flex">
        <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
        <button class="btn btn-outline-success" type="submit">Search</button>
      </form>
    </div>
  </div>
</nav>

Çepde görkezilen marka ady we sag tarapda üýtgetmek:

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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 me-auto mb-2 mb-lg-0">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
        </li>
      </ul>
      <form class="d-flex">
        <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
        <button class="btn btn-outline-success" type="submit">Search</button>
      </form>
    </div>
  </div>
</nav>

Çepde açar we sagda marka ady bilen:

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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 me-auto mb-2 mb-lg-0">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
        </li>
      </ul>
      <form class="d-flex">
        <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
        <button class="btn btn-outline-success" type="submit">Search</button>
      </form>
    </div>
  </div>
</nav>

Daşarky mazmun

Käwagt strukturalaýyn daşynda ýerleşýän mazmun üçin konteýner elementini işletmek üçin çökmek plaginini ulanmak isleýärsiňiz .navbar. Biziň pluginimiz gabat gelýän idwe data-bs-targetişleýänligi sebäpli, aňsatlyk bilen ýerine ýetirilýär!

<div class="collapse" id="navbarToggleExternalContent">
  <div class="bg-dark p-4">
    <h5 class="text-white h4">Collapsed content</h5>
    <span class="text-muted">Toggleable via the navbar brand.</span>
  </div>
</div>
<nav class="navbar navbar-dark bg-dark">
  <div class="container-fluid">
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
  </div>
</nav>

Muny ýerine ýetireniňizde, fokus açylanda konteýnerine programma taýdan geçirmek üçin goşmaça JavaScript goşmagy maslahat berýäris. Otherwiseogsam, klawiaturany ulanýanlar we kömekçi tehnologiýalary ulanýanlar täze açylan mazmuny tapmakda kynçylyk çekerler - esasanam açylan konteýner resminamanyň gurluşynda açylmazdan ozal . Mundan başga-da, göçürijiniň mazmun konteýneriniň mazmunyny aria-controlsgörkezip , häsiýetiniň bardygyna göz ýetirmegi maslahat berýäris . idTeoriýa boýunça, bu kömekçi tehnologiýa ulanyjylaryna gönüden-göni gözegçilikden geçirýän konteýnerine bökmäge mümkinçilik berýär - ýöne häzirki wagtda bu goldaw gaty kyn.

Sass

Üýtgeýjiler

$navbar-padding-y:                  $spacer * .5;
$navbar-padding-x:                  null;

$navbar-nav-link-padding-x:         .5rem;

$navbar-brand-font-size:            $font-size-lg;
// Compute the navbar-brand padding-y so the navbar-brand will have the same height as navbar-text and nav-link
$nav-link-height:                   $font-size-base * $line-height-base + $nav-link-padding-y * 2;
$navbar-brand-height:               $navbar-brand-font-size * $line-height-base;
$navbar-brand-padding-y:            ($nav-link-height - $navbar-brand-height) * .5;
$navbar-brand-margin-end:           1rem;

$navbar-toggler-padding-y:          .25rem;
$navbar-toggler-padding-x:          .75rem;
$navbar-toggler-font-size:          $font-size-lg;
$navbar-toggler-border-radius:      $btn-border-radius;
$navbar-toggler-focus-width:        $btn-focus-width;
$navbar-toggler-transition:         box-shadow .15s ease-in-out;
$navbar-dark-color:                 rgba($white, .55);
$navbar-dark-hover-color:           rgba($white, .75);
$navbar-dark-active-color:          $white;
$navbar-dark-disabled-color:        rgba($white, .25);
$navbar-dark-toggler-icon-bg:       url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'><path stroke='#{$navbar-dark-color}' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/></svg>");
$navbar-dark-toggler-border-color:  rgba($white, .1);

$navbar-light-color:                rgba($black, .55);
$navbar-light-hover-color:          rgba($black, .7);
$navbar-light-active-color:         rgba($black, .9);
$navbar-light-disabled-color:       rgba($black, .3);
$navbar-light-toggler-icon-bg:      url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'><path stroke='#{$navbar-light-color}' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/></svg>");
$navbar-light-toggler-border-color: rgba($black, .1);

$navbar-light-brand-color:                $navbar-light-active-color;
$navbar-light-brand-hover-color:          $navbar-light-active-color;
$navbar-dark-brand-color:                 $navbar-dark-active-color;
$navbar-dark-brand-hover-color:           $navbar-dark-active-color;

Aýlaw

Jogapkärçilikli gämi paneli giňeltmek / ýykmak synplary (meselem, .navbar-expand-lg) $breakpointskarta bilen birleşdirilip, bir aýlaw arkaly döredilýär scss/_navbar.scss.

// Generate series of `.navbar-expand-*` responsive classes for configuring
// where your navbar collapses.
.navbar-expand {
  @each $breakpoint in map-keys($grid-breakpoints) {
    $next: breakpoint-next($breakpoint, $grid-breakpoints);
    $infix: breakpoint-infix($next, $grid-breakpoints);

    // stylelint-disable-next-line scss/selector-no-union-class-name
    &#{$infix} {
      @include media-breakpoint-up($next) {
        flex-wrap: nowrap;
        justify-content: flex-start;

        .navbar-nav {
          flex-direction: row;

          .dropdown-menu {
            position: absolute;
          }

          .nav-link {
            padding-right: $navbar-nav-link-padding-x;
            padding-left: $navbar-nav-link-padding-x;
          }
        }

        .navbar-nav-scroll {
          overflow: visible;
        }

        .navbar-collapse {
          display: flex !important; // stylelint-disable-line declaration-no-important
          flex-basis: auto;
        }

        .navbar-toggler {
          display: none;
        }
      }
    }
  }
}