Navbar nisqa
Qillqakuna chaymanta ejemplokuna Bootstrap kallpasapa, kutichiq puriy umalliqpaq, navbar kaqpaq. Yanapakuy markapaq, puriypaq, urmachiy plugin kaqpaq chaymanta aswanta yapan.
Imayna llamkan
Kaypi yachanayki tiyan manaraq navbar kaqwan qallarichkaspa:
- Navbars huk p'istuyta munan
.navbar
kutichiq.navbar-expand{-sm|-md|-lg|-xl}
urmaypaq chaymanta llimp'i esquema clasekuna kaqpaq. - Navbars chaymanta contenidosninkuqa fluido kanku ñawpaqmanta. Utilizar contenedores opcionales para limitar su ancho horizontal.
- Espaciamiento chaymanta flex utilidad claseykuta llamk'achiy espaciamiento chaymanta alineación kamachiypaq navbars ukhupi.
- Navbars kutichiq kanku ñawpaqmanta, ichaqa chayta tikranaykipaq mana sasachu tikrayta atikunki. Kutichiy ruwayqa Collapse JavaScript pluginniykumanta kanqa.
- Navbarkuna ñawpaqmanta pakasqa kachkan imprimiypi.
.d-print
Chaykunata impriminankupaq obligay, chayman yapaspa.navbar
. Qhawachiy yanapakuy claseta qhaway . - Huk elementota llamk'achispa yaykuy atiyta qhaway
<nav>
utaq, sichus huk aswan genérico elementota llamk'achkanki kayhina huk<div>
, huk sapa navbar kaqman yapayrole="navigation"
sut'imanta riqsichinapaq huk suyu suyu hina yanapakuq tecnologiakuna llamk'aqkunapaq.
prefers-reduced-motion
medios tapuymanta hapirin. Yaykuna qillqaykumanta pisiyachisqa kuyuy t'aqapi qhaway
.
Yanapasqa contenido
Navbars huk makilla sub-componentes kaqpaq ruwasqa yanapakuywan hamunku. Necesitasqaykiman hina kaykunata akllay:
.navbar-brand
empresaykipaq, ruruykipaq utaq proyecto sutiykipaq..navbar-nav
huk hunt'a sayayniyuq chaymanta llamp'u puriypaq (urqunapaq yanapakuywan kuska)..navbar-toggler
urmachiy pluginniykuwan chaymanta wak puriy tikray ruwaykunawan llamk'anapaq..form-inline
ima forma controles nisqapaqpas ruwaykunapaqpas..navbar-text
sayaq chawpichasqa qillqap watiqankunata yapanapaq..collapse.navbar-collapse
navbarpa imayna kanankunata huk tayta rakinawan huñunapaq chaymanta pakanapaq.
Kaypi huk ejemplo llapa sub-componentes kaqmanta huk kutichiq k'anchay-tema navbar kaqpi churasqa chaymanta kikinmanta urmayku lg
(hatun) p'akiypi.
<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="#" role="button" data-toggle="dropdown" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu">
<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">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>
Kay rikch'anaqa llimp'i ( bg-light
) chaymanta espaciamiento ( my-2
, my-lg-0
, mr-sm-0
, my-sm-0
) yanapakuy clasekunata llamk'achin.
Marca
The .navbar-brand
aswan elementokunaman churakunman, ichaqa huk ancla aswan allinta llamkan, wakin elementokuna yanapakuy clasekuna utaq sapanchasqa estilokuna mañakunman hina.
<!-- 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>
Siq'ikunata yapayqa .navbar-brand
sapa kuti sapanchasqa estilokuna utaq yanapakuykunata allin sayaypaq mañanqa. Kaypi wakin ejemplokunata qawachinapaq.
<!-- Just an image -->
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand" href="#">
<img src="/docs/4.6/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.6/assets/brand/bootstrap-solid.svg" width="30" height="30" class="d-inline-block align-top" alt="">
Bootstrap
</a>
</nav>
Nav
Navbar puriy t'inkikuna .nav
akllanaykupi ruwanku kikin tikraq clase kaqwan chaymanta toggler clasekuna llamk'ayta munanku allin kutichiq estilopaq. Navbarkunapi puriypas wiñanqa aswan horizontal espaciota hap'inanpaq atikuq hina navbar kaqpi contenidokunayki allin chiqanchasqa kananpaq.
Ruwasqa estadokuna .active
—wan —kunan p'anqata rikuchinapaq chiqalla .nav-link
s kaqman utaq chaylla tayta mamankuman .nav-item
s kaqman churakunman.
<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">Disabled</a>
</li>
</ul>
</div>
</nav>
Hinallataq imaraykuchus navsniykupaq clasekunata llamk'achiyku, lista-based enfoqueta tukuyninpi hark'ayta atikunki sichus munanki.
<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-link active" href="#">Home <span class="sr-only">(current)</span></a>
<a class="nav-link" href="#">Features</a>
<a class="nav-link" href="#">Pricing</a>
<a class="nav-link disabled">Disabled</a>
</div>
</div>
</nav>
Navbar nisqaykipipas urayk'achiqkunatam llamk'achiyta atinki. Uray menúkuna huk p'istu elementota churanapaq munanku, chayrayku ama hina kaspa sapaq chaymanta anidado elementokuna llamk'achiyta .nav-item
chaymanta .nav-link
uraypi rikuchisqa hina.
<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="#" role="button" data-toggle="dropdown" aria-expanded="false">
Dropdown link
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
</ul>
</div>
</nav>
Formas
Imaymana formulario kamachiykunata chaymanta componentekunata huk navbar ukhupi churay .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>
Chaylla wawa elementokuna .navbar
llamk'achiyta flex churaymanta chaymanta ñawpaqmanta churasqa kanqa justify-content: space-between
. Kay ruwayta allichanapaq necesitasqanmanhina yapasqa flex yanapakuykunata llamk'achiy.
<nav class="navbar navbar-light bg-light">
<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>
Yaykuy huñukunapas llamkanku, chaynallataq:
<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>
Imaymana botones yanapasqa kanku kay navbar formulariokuna huknin hina, chaymanta. Kayqa huk hatun yuyarichiypas kan, sayaq chiqanchay yanapakuykunata hukniray sayayniyuq elementokunata chiqanchaypaq llamk'achiy atikun.
<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>
Qillqa
Navbars nisqapiqa qillqasqapa bits nisqakunam kanman .navbar-text
. Kay claseqa qillqap watiqankunapaq sayaq chiqanchayta, sayaq chiqanchayta ima allichan.
<nav class="navbar navbar-light bg-light">
<span class="navbar-text">
Navbar text with an inline element
</span>
</nav>
Huk componentekunawan chaymanta utilidadkunawan necesitasqanmanhina chaqruspa tupachiy.
<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>
Esquemas de colores
Temachay navbar mana hayk'aqpas aswan facilchu karqan gracias chay combinación de clases de temas y background-color
utilidades. Akllay .navbar-light
k'anchay qhipa llimp'ikunawan llamk'anapaq, utaq .navbar-dark
yana qhipa llimp'ikunapaq. Chaymanta, .bg-*
utilidadkunawan ruway.
<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>
Contenedores
Mana kamachisqa kaptinpas, huk navbarta .container
huk p'anqapi chawpichaypaq p'anqayta atinki. Utaq huk waqaychana ukhupi yapayta atikunki huk takyasqa utaq mana kuyusqa pata navbar.navbar
kaqpa kaqninkunallata chawpichaypaq .
<div class="container">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
</nav>
</div>
Mayk'aq waqaychana navbarniyki ukhupi kachkan, paypaq horizontal acolchado kaqninta aswan pisi p'akiy puntokunapi hurqusqa .navbar-expand{-sm|-md|-lg|-xl}
claseykimanta. Kayqa mana iskay kutita ruwachkaykuchu rellenopi mana necesariota uray qhawanakunapi mayk'aq navbarniyki urmasqa kachkan.
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand" href="#">Navbar</a>
</div>
</nav>
Colocación
Posición yanapakuyniyku llamk'achiy navbars mana estático posiciónkunapi churanapaq. Akllay pataman takyasqa, urayman takyasqa utaq pataman k'askasqa (p'anqawan kuyuy pataman chayanankama, chaymanta chaypi qhipakun). Allinchasqa navbarkuna llamk'achinku position: fixed
, niyta munan paykuna DOM kaqpa normal puriyninmanta aysasqa kanku chaymanta sapanchasqa CSS (kayhina, padding-top
kaqpi <body>
) huk elementokunawan mana tupachiyta mañakunman.
Hinallataq reparay chayta .sticky-top
llamk'achin position: sticky
, mayqinchus mana tukuy maskaqpi tukuy yanapasqachu .
<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>
Desplazamiento
.navbar-nav-scroll
Huk (utaq huk navbar sub-componente kaqman) yapay , .navbar-collapse
sayaq kuyuchiyta atichinanpaq huk urmasqa navbar kaqpa tikranapaq kaqnin ukhupi. Ñawpaqmanta, kuyuchiyqa 75vh
(utaq 75% qhaway punku sayaymanta) qallarikun, ichaqa chayta chiru ukhupi utaq sapanchasqa estilokunawan llalliyta atikunki. Aswan hatun qhawanakunapi mayk'aq navbar mast'arisqa, contenido rikhurinqa imaynachus huk ñawpaqmanta navbar kaqpi ruwan.
Ama hina kaspa, kay ruway huk mana allin atiywan hamun overflow
—mayk'aq churay overflow-y: auto
(kaypi willayta kuyuchinapaq mañasqa), overflow-x
, kaqwan kikin kachkan auto
, mayqinchus wakin horizontal willayta kuchunqa.
Kaypi huk ejemplo navbar kaqwan llamk'achkan .navbar-nav-scroll
, style="max-height: 100px;"
wakin yapasqa margen yanapakuykunawan allin espaciamiento kaqpaq.
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar scroll</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-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 mr-auto my-2 my-lg-0 navbar-nav-scroll" style="max-height: 100px;">
<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="#" role="button" data-toggle="dropdown" aria-expanded="false">
Link
</a>
<ul class="dropdown-menu">
<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 mr-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</nav>
Kutichiq ruwaykuna
Navbars .navbar-toggler
, .navbar-collapse
, chaymanta .navbar-expand{-sm|-md|-lg|-xl}
clasekuna llamk'achiyta atinku mayk'aqchus contenidonku huk ñit'ina qhipanpi urmaykusqanmanta yachanapaq. Huk yanapakuykunawan kuskachasqa, mana sasachu akllayta atikunki mayk'aq rikuchiyta utaq pakayta wakin elementokunata.
Mana hayk'aqpas urmaq navbarkunapaq, .navbar-expand
navbar kaqpi claseta yapay. Sapa kuti urmaq navbarkunapaq, ama ima .navbar-expand
clasetapas yapaychu.
Toggler nisqa
Navbar tikraqkuna ñawpaqmanta lluq'i-t'inkisqa kanku, ichaqa huk wawqi elementota huk hina qatiptinkuqa .navbar-brand
, kikinmanta karu pañaman chiqanchasqa kanqa. Markayki tikrayqa tikraqpa churayninta tikranqa. Uraypi hukhina toggle estilokunamanta ejemplokuna kachkan.
.navbar-brand
Aswan huch'uy p'akiypi mana rikuchisqa kaptin:
<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">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>
Lloq’e ladopi rikuchisqa marca sutiwan, paña ladopitaq toggler nisqawan:
<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">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>
Lloq’e ladopi huk toggler nisqawan, paña ladopitaq marca sutiwan:
<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">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>
Hawamanta willakuy
Wakin kuti, urmachiy plugin llamk'achiyta munanki huk waqaychana elementota llamk'achinapaq, estructuralmente hawapi tiyaq contenidopaq .navbar
. Imaraykuchus pluginniyku llamk'an id
chaymanta data-target
tupachiypi, chayqa facil ruwakun!
<div class="fixed-top">
<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">
<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>
Kayta ruwanki, huk JavaScript yapasqa churayta yuyaychayku, kichasqa kaqtin programamanta enfoqueta waqaychanaman kuyuchinapaq. Mana hina kaqtinqa, teclado kaqmanta llamk'aqkuna chaymanta yanapakuq tecnologiakuna kaqmanta llamk'aqkuna ichapas sasachakuyniyuq kanqanku musuq rikuchisqa willayta tarinankupaq - aswanta sichus kichasqa waqaychana qillqap ruwayninpi toggler ñawpaqninpi hamun. Hinallataq, toggler aria-controls
atributoyuq kasqanmanta qhawayta yuyaychayku, id
chaymanta chay contenido waqaychanamanta rikuchispa. Teoría kaqpi, kayqa yanapakuq tecnologia kaqmanta ruwaqkunaman chiqamanta saltayta saqin kay toggler kaqmanta chaymanta controlasqan waqaychanaman–ichaqa kaypaq yanapakuy kunan pacha ancha parche kaqwan kachkan.