Fa'asolo ile anotusi autu Fa'asolo ile fa'ata'ita'iga o fa'amatalaga
in English

Navbar

Fa'amaumauga ma fa'ata'ita'iga mo le fa'auluuluga fa'atonu mamana a Bootstrap, le navbar. E aofia ai le lagolago mo le fa'ailogaina, fa'atautaiga, ma isi mea, e aofia ai le lagolago mo la tatou fa'apalapala pa'u.

E faapefea ona galue

O mea nei e tatau ona e iloa ae e te leʻi amataina le navbar:

  • Navbars e manaʻomia se afifiina mo vasega pa'u ma .navbarlanu lanu ..navbar-expand{-sm|-md|-lg|-xl|-xxl}
  • Navbars ma a latou mea o loʻo i totonu o loʻo faʻafefe ona o le faaletonu. Suia le atigipusa e faʻatapulaʻa le lautele faʻalava i auala eseese.
  • Fa'aoga a matou va'aiga ma fetu'utu'una'i vasega aoga mo le fa'atonutonuina o le va ma le fa'aogaina i totonu o navbars.
  • Navbars e tali mai e ala i le le mafai, ae e faigofie ona e suia e sui ai lena mea. O amioga tali atu e fa'alagolago i la matou Collapse JavaScript plugin.
  • Fa'amautinoa le fa'aogaina e ala i le fa'aogaina o se <nav>elemene po'o, pe a fa'aaogaina se elemene e sili atu le lautele e pei o le <div>, fa'aopoopo se role="navigation"i luga ole navbar uma e fa'ailoa manino ai o se fa'ailoga mata'ina mo tagata fa'aoga tekinolosi fesoasoani.
  • Fa'ailoa le mea o lo'o i ai nei e ala i le fa'aoga aria-current="page"mo le itulau o lo'o i ai nei po'o aria-current="true"le mea o lo'o iai nei i se seti.
O le aafiaga o le animation o lenei vaega e fa'alagolago i le su'esu'ega a le prefers-reduced-motionaufaasālalau. Va'ai le vaega fa'aitiitiga fa'aitiitiga oa matou pepa fa'aoga avanoa .

Mea e lagolagoina

Navbars e sau ma faʻapipiʻi i totonu o le lagolago mo ni nai vaega laiti. Filifili mai mea nei pe a manaʻomia:

  • .navbar-brandmo lau kamupani, oloa, po'o le igoa ole poloketi.
  • .navbar-navmo se folauga maualuga ma mama (e aofia ai le lagolago mo pa'u i lalo).
  • .navbar-togglermo le fa'aoga i la matou fa'apalapala pa'u ma isi fa'asologa aga fa'asolo .
  • Feso'ota'i ma fa'aoga avanoa mo so'o se fa'atonuga ma gaioiga.
  • .navbar-textmo le fa'aopoopoina o manoa fa'atotonugatotonu i luga o le laina o tusitusiga.
  • .collapse.navbar-collapsemo le fa'avasegaina ma le nanaina o mea o lo'o i totonu o le navbar e ala i se va'aiga matua.
  • Fa'aopoopo i ai se filifiliga .navbar-scrolle seti ai max-heightma fa'asolo le fa'alauteleina o mea navbar .

O se fa'ata'ita'iga lea o vaega laiti uma o lo'o aofia i totonu o se navbar e fa'atatau i le malamalama e otometi lava ona pa'u ile lg(tele) malepe.

<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">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>

O lenei fa'ata'ita'iga e fa'aoga ai le talaaga ( bg-light) ma le va'aiga ( my-2, my-lg-0, me-sm-0, my-sm-0) vasega aoga.

Fa'ailoga

E .navbar-brandmafai ona fa'aoga i le tele o elemene, ae e sili ona aoga le taula, ona o nisi elemene e ono mana'omia ai vasega aoga po'o sitaili masani.

Tusitusi

Fa'aopoopo lau tusitusiga i totonu o se elemene ma le .navbar-brandvasega.

<!-- 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>

Ata

E mafai ona e suia le tusitusiga i totonu o .navbar-brandle <img>.

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

Ata ma tusitusiga

E mafai fo'i ona e fa'aogaina nisi fa'aoga fa'aopoopo e fa'aopoopo ai se ata ma tusitusiga i le taimi e tasi. Matau le faaopoopoga o .d-inline-blockma .align-text-topluga o le <img>.

<nav class="navbar navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">
      <img src="/docs/5.1/assets/brand/bootstrap-logo.svg" alt="" width="30" height="24" class="d-inline-block align-text-top">
      Bootstrap
    </a>
  </div>
</nav>

Navbar navigation links e fausia i luga oa tatou .navfilifiliga ma a latou lava vasega faʻaleleia ma manaʻomia le faʻaogaina o vasega toggler mo le faʻaogaina talafeagai. O le a fa'atupula'ia fo'i le fa'atauta'iga i luga ole laiga e nofoia le tele o avanoa fa'ata'amilo e mafai ai ona fa'atutu lelei lau fa'aoga o le navbar.

Fa'aopoopo le .activevasega .nav-linke fa'ailoa ai le itulau o lo'o iai nei.

Faamolemole ia matau e tatau foi ona e faaopoopo i ai le aria-currentuiga i le active .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">Disabled</a>
        </li>
      </ul>
    </div>
  </div>
</nav>

Ma talu ai matou te faʻaogaina vasega mo a matou navs, e mafai ona e aloese mai le faʻaogaina o le lisi atoa pe a e fiafia i ai.

<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">Disabled</a>
      </div>
    </div>
  </div>
</nav>

E mafai fo'i ona e fa'aogaina fa'alalo i lau navbar. E mana'omia e menus dropdown se mea afifi mo le fa'atulagaina, o lea ia mautinoa e fa'aaoga elemene eseese ma fa'aputu mo .nav-itemma .nav-linkpei ona fa'aalia i lalo.

<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>

Fomu

Tu'u ni fa'atonuga ma vaega 'ese'ese i totonu ole navbar:

<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>

Elemene a tamaiti o le .navbarfa'aoga fetuutuuna'i le fa'atulagaina ma o le a fa'aletonu i le justify-content: space-between. Fa'aoga mea fa'aoga fetuutuunai pe a mana'omia e fa'afetaui ai lenei amio.

<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>

E galue fo'i vaega fa'aoga. Afai o lau navbar o se foliga atoa, poʻo le tele o se fomu, e mafai ona e faʻaogaina le <form>elemene e fai ma atigipusa ma faʻasaoina nisi HTML.

<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>

O fa'amau eseese o lo'o lagolagoina o se vaega o nei fomu navbar, fo'i. Ose fa'amanatu sili foi lea e mafai ona fa'aoga mea fa'aoga fa'atutusa e fa'aoga ai elemene eseese.

<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>

Tusitusi

Navbars e mafai ona i ai ni vaega o tusitusiga ma le fesoasoani a .navbar-text. O lenei vasega e fetu'una'i le fa'asolo i luga ma le avanoa fa'alava mo manoa o tusitusiga.

<nav class="navbar navbar-light bg-light">
  <div class="container-fluid">
    <span class="navbar-text">
      Navbar text with an inline element
    </span>
  </div>
</nav>

Faafefiloi ma fetaui ma isi vaega ma mea aoga pe a manaʻomia.

<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>

Fa'ailoga lanu

O le faʻaogaina o le navbar e leʻi faigofie lava faʻafetai i le tuʻufaʻatasia o vasega autu ma background-colormea aoga. Filifili mai .navbar-lightmo le fa'aoga i lanu malamalama i tua, pe .navbar-darkmo lanu pogisa. Ona, faʻavasegaina ma .bg-*mea faʻaoga.

<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>

Koneteina

E ui lava e le manaʻomia, e mafai ona e afifiina se navbar i totonu .containere faʻatotonu i luga o se itulau-e ui o loʻo manaʻomia se atigipusa i totonu. Pe mafai ona e fa'aopopoina se atigipusa i totonu o le .navbarfa'atotonugalemu o mea o lo'o i totonu o se fa'amaufa'ailoga pito i luga navbar .

<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>

Fa'aoga so'o se koneteina tali mai e sui ai le lautele o mea o lo'o fa'aalia i lau navbar.

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

Tulaga

Fa'aoga a matou tulaga fa'aoga e tu'u ai navbars i tulaga e le fa'amautu. Filifili mai le fa'amau i le pito i luga, fa'amau i lalo, po'o le pipii i le pito i luga (ta'ai ma le itulau se'ia o'o i le pito i luga, ona nofo ai lea iina). Fa'aoga navbars fa'amaumau position: fixed, o lona uiga e toso mai le tafe masani a le DOM ma e ono mana'omia le CSS masani (fa'ata'ita'iga, padding-topi luga o le <body>) e puipuia ai le sosolo ma isi elemene.

Ia maitauina foi o le .sticky-topfa'aoga position: sticky, lea e le'o lagolagoina atoatoa i so'o se su'esu'ega .

<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>

Tusitala

Fa'aopoopo .navbar-nav-scrolli se .navbar-nav(po'o se isi vaega o le navbar) ina ia mafai ai ona ta'ai sa'o i totonu o mea e mafai ona fesuia'i o se navbar ua pa'u. E le mafai, o le taʻavale e kiki i totonu 75vh(poʻo le 75% o le maualuga o le vaʻaia), ae e mafai ona e faʻaogaina i le CSS mea totino --bs-navbar-heightmasani poʻo sitaili masani. I va'aiga tetele pe a fa'alautele le navbar, o le a fa'aalia mea o lo'o i ai i totonu o le navbar fa'aletonu.

Faamolemole ia matau o lenei amioga e sau faatasi ma se faaletonu o le overflow-pe a setiina overflow-y: auto(manaomia e ta'ai ai le anotusi iinei), overflow-xe tutusa ma le auto, lea o le a tipiina ai nisi mea faalava.

O se fa'ata'ita'iga navbar fa'aoga .navbar-nav-scrollma le style="--bs-scroll-height: 100px;", fa'atasi ai ma nisi fa'aoga fa'asili mo le avanoa sili ona lelei.

<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">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>

Amioga tali atu

E mafai e Navbars ona fa'aoga .navbar-toggler, .navbar-collapse, ma .navbar-expand{-sm|-md|-lg|-xl|-xxl}vasega e iloa ai pe o a latou mea e pa'u i tua o se ki. Faʻatasi ma isi faʻaoga, e faigofie ona e filifilia le taimi e faʻaalia pe nana ai elemene faapitoa.

Mo navbars e le mafai ona pa'u, fa'aopoopo le .navbar-expandvasega ile navbar. Mo navbars e pa'u i taimi uma, aua le fa'aopoopoina se .navbar-expandvasega.

Toggler

Navbar togglers o lo'o fa'aoga agavale ona o le fa'aletonu, ae afai latou te mulimuli i se uso e pei o le .navbar-brand, o le a otometi lava ona fa'aoga i le itu taumatau. O le toe fesuia'i o lau fa'ailoga o le a toe fa'afo'i ai le tu'uga o le koli. O lo'o i lalo ni fa'ata'ita'iga o sitaili fe'avea'i eseese.

E aunoa ma se .navbar-brandfa'aalia i le pito la'ititi la'ititi:

<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">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>

Faatasi ai ma se igoa faʻailoga o loʻo faʻaalia i le agavale ma le toggle i le taumatau:

<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">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>

Faatasi ai ma se koli i le agavale ma le igoa fa'ailoga i le taumatau:

<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">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>

Anotusi fafo

O nisi taimi e te manaʻo e faʻaoga le faʻapipiʻi paʻu e faʻaosoina ai se atigipusa elemene mo mea o loʻo nofo i fafo o le .navbar. Ona o le matou plugin e galue i luga o le idma data-bs-targetfetaui, e faigofie lava ona fai!

<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>

A e faia lea mea, matou te fautuaina le fa'aopoopoina o le Javascript e fa'agasolo ai le taula'i fa'apolokalame i le koneteina pe a tatala. A leai, o le a faigata i tagata fa'aoga keyboard ma tagata fa'aogaina tekinolosi fesoasoani i le sailia o mea fou na fa'aalia - ae maise lava pe afai o le koneteina na tatalaina e sau i luma o le toggle i le fausaga o le pepa. Matou te fautuaina foi ia mautinoa o loʻo i ai i le toggles le aria-controlsuiga, faʻasino i le idmea o loʻo i totonu. I le a'oa'oga, e mafai ai e tagata fa'aoga tekinolosi fesoasoani ona oso sa'o mai le toggle i le koneteina o lo'o pulea-ae o le lagolago mo lenei mea o lo'o fai si fa'aletonu.

Fa'alavalava

Suia lau navbar fa'alautele ma pa'u i totonu o se atigi tapoleni fa'atasi ai ma le fa'apipi'i offcanvas. Matou te fa'alauteleina uma sitaili fa'aletonu i fafo ma fa'aoga a matou .navbar-expand-*vasega e fai ai se itu fa'atauva'a fa'amalosi ma fetu'una'i.

I le fa'ata'ita'iga o lo'o i lalo, e fa'atupu ai se fa'alava fa'alava e fa'ase'e i taimi uma i va'aiga uma, fa'ate'a .navbar-expand-*atoa le vasega.

<nav class="navbar navbar-light bg-light fixed-top">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Offcanvas navbar</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasNavbar" aria-controls="offcanvasNavbar">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasNavbar" aria-labelledby="offcanvasNavbarLabel">
      <div class="offcanvas-header">
        <h5 class="offcanvas-title" id="offcanvasNavbarLabel">Offcanvas</h5>
        <button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
      </div>
      <div class="offcanvas-body">
        <ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
          <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="offcanvasNavbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
              Dropdown
            </a>
            <ul class="dropdown-menu" aria-labelledby="offcanvasNavbarDropdown">
              <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>
        </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>
  </div>
</nav>

Ina ia fatuina se navbar offcanvas e faʻalautele i se faʻailoga masani i se nofoaga faʻapitoa e pei o lgle , faʻaaoga .navbar-expand-lg.

<nav class="navbar navbar-light navbar-expand-lg bg-light fixed-top">
  <a class="navbar-brand" href="#">Offcanvas navbar</a>
  <button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#navbarOffcanvasLg" aria-controls="navbarOffcanvasLg">
    <span class="navbar-toggler-icon"></span>
  </button>
  <div class="offcanvas offcanvas-end" tabindex="-1" id="navbarOffcanvasLg" aria-labelledby="navbarOffcanvasLgLabel">
    ...
  </div>
</nav>

Sass

Fuafuaga

$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;

Ta'amilosaga

Navbar tali fa'alautele/fa'alalo vasega (fa'ata'ita'iga, .navbar-expand-lg) e tu'ufa'atasia ma le $breakpointsfa'afanua ma fa'atupuina e ala i se matasele i 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;
        }

        .offcanvas-header {
          display: none;
        }

        .offcanvas {
          position: inherit;
          bottom: 0;
          z-index: 1000;
          flex-grow: 1;
          visibility: visible !important; // stylelint-disable-line declaration-no-important
          background-color: transparent;
          border-right: 0;
          border-left: 0;
          @include transition(none);
          transform: none;
        }
        .offcanvas-top,
        .offcanvas-bottom {
          height: auto;
          border-top: 0;
          border-bottom: 0;
        }

        .offcanvas-body {
          display: flex;
          flex-grow: 0;
          padding: 0;
          overflow-y: visible;
        }
      }
    }
  }
}