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
.navbar
lanu 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 serole="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'oaria-current="true"
le mea o lo'o iai nei i se seti.
prefers-reduced-motion
aufaasā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-brand
mo lau kamupani, oloa, po'o le igoa ole poloketi..navbar-nav
mo se folauga maualuga ma mama (e aofia ai le lagolago mo pa'u i lalo)..navbar-toggler
mo 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-text
mo le fa'aopoopoina o laina fa'aogatotonu i luga o le sa'o o tusitusiga..collapse.navbar-collapse
mo 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-scroll
e seti aimax-height
ma 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" 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>
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-brand
mafai ona faʻaoga i le tele o elemene, ae 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-brand
vasega.
<!-- 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-brand
le <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>
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-block
ma .align-text-top
luga o le <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>
Nav
Navbar navigation links e fausia i luga oa tatou .nav
filifiliga 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 .active
vasega .nav-link
e fa'ailoa ai le itulau o lo'o iai nei.
Faamolemole ia matau e tatau foi ona e faaopoopo i ai le aria-current
uiga 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" href="#" tabindex="-1" aria-disabled="true">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" href="#" tabindex="-1" aria-disabled="true">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 elemene afifi mo le fa'atulagaina, ia mautinoa e fa'aaoga elemene eseese ma fa'aputu mo .nav-item
ma .nav-link
pei 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 .navbar
fa'aoga fetuutuuna'i le fa'atulagaina ma o le a fa'aletonu i le justify-content: space-between
. Fa'aaogā mea fa'aoga felefele fa'aopoopo 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 pepa atoa, poʻo le tele o se fomu, e mafai ona e faʻaogaina le <form>
elemene e fai ma pusa 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-color
mea aoga. Filifili mai .navbar-light
mo le fa'aoga i lanu malamalama i tua, pe .navbar-dark
mo 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 .container
e faʻatotonu i luga o se itulau-e ui o loʻo manaʻomia se atigipusa i totonu. Pe mafai ona e fa'aopoopoina se atigipusa i totonu o le .navbar
na'o totonugalemu o mea o lo'o i totonu o se fa'amaufa'ailoga pito i luga .
<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-top
i luga o le <body>
) e puipuia ai le sosolo ma isi elemene.
Ia maitauina foi o le .sticky-top
fa'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-scroll
i se .navbar-nav
(po'o se isi vaega o le navbar) ina ia mafai ai ona ta'avale i luga i luga o le mea e mafai ona fesuia'i i totonu 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-height
masani poʻo sitaili masani. I va'aiga lapopoa pe a fa'alautele le navbar, o le a fa'aalia mea e pei ona i ai i 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-x
e tutusa ma le auto
, lea o le a tipiina ai nisi mea faalava.
O se fa'ata'ita'iga navbar fa'aoga .navbar-nav-scroll
ma 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" 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>
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-expand
vasega ile navbar. Mo navbars e pa'u i taimi uma, aua le fa'aopoopoina se .navbar-expand
vasega.
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-brand
fa'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" 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>
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" 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>
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" 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>
Anotusi fafo
O nisi taimi e te manaʻo e faʻaoga le faʻapipiʻi pa'ū 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 id
ma data-bs-target
fetaui, 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 lenei mea, matou te fautuaina le faʻaopoopoina o le JavaScript e faʻanofo ai le taulaiga faʻapolokalame i le koneteina pe a tatalaina. 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-controls
uiga, faʻasino i le id
mea 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.
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 $breakpoints
fa'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;
}
}
}
}
}