SourceIbha ye-Navbar
Amadokhumenti nezibonelo zesihloko sokuzulazula esinamandla, esisabelayo se-Bootstrap, ibha ye-navbar. Kufaka usekelo lwebhrendi, ukuzulazula, nokunye okwengeziwe, okuhlanganisa usekelo lwe-plugin yethu yokugoqa.
Isebenza kanjani
Nakhu okudingeka ukwazi ngaphambi kokuthi uqale nge-navbar:
- Ama-Navbar adinga ukugoqwa ukuze aphendule ukugoqa
.navbar
namakilasi esikimu sombala ..navbar-expand{-sm|-md|-lg|-xl}
- Ama-Navbar nokuqukethwe kwawo kuwuketshezi ngokuzenzakalelayo. Sebenzisa iziqukathi ozikhethela ukuze ukhawulele ububanzi bazo obuvundlile.
- Sebenzisa izikhala zethu kanye namakilasi ezinsiza eziguquguqukayo ukuze ulawule isikhala nokuqondanisa ngaphakathi kwama-navbar.
- Ama-Navbar aphendula ngokuzenzakalelayo, kodwa ungakwazi ukuwashintsha kalula ukuze ashintshe lokho. Ukuziphatha okusabelayo kuncike ku-plugin yethu ye-Collapse JavaScript.
- Ama-Navbar afihlwa ngokuzenzakalelayo lapho uphrinta. Phoqa ukuthi aphrintwe ngokungeza kufayela
.d-print
le- .navbar
. Bona ikilasi lensiza yokubonisa .
- Qinisekisa ukufinyeleleka ngokusebenzisa i-
<nav>
elementi noma, uma usebenzisa i-elementi evamile njenge- <div>
, engeza i- role="navigation"
navbar ngayinye ukuze uyikhombe ngokusobala njengesifunda esiyingqopha-mlando kubasebenzisi bobuchwepheshe obusizayo.
Qhubeka ufunde ukuze uthole isibonelo kanye nohlu lwezingxenye ezincane ezisekelwayo.
Okuqukethwe okusekelwe
Ama-Navbar eza nosekelo olwakhelwe ngaphakathi lwezingxenye ezincane ezimbalwa. Khetha kokulandelayo njengoba kudingeka:
.navbar-brand
inkampani yakho, umkhiqizo, noma igama lephrojekthi.
.navbar-nav
ukuze uthole ukuzulazula okugcwele ubude nokungasindi (okuhlanganisa nosekelo lokwehliswayo).
.navbar-toggler
ukuze sisetshenziswe ne-plugin yethu yokugoqa nokunye ukuziphatha kokuguqula indlela yokuzulazula.
.form-inline
nganoma yiziphi izilawuli nezenzo zefomu.
.navbar-text
yokwengeza amayunithi ezinhlamvu aphakathi nendawo aqondile.
.collapse.navbar-collapse
ukuze uqoqe futhi ufihle okuqukethwe kwe-navbar ngephuzu lomzali.
Nasi isibonelo sazo zonke izingxenye ezingaphansi ezifakwe ku-navbar enetimu yokukhanya esabelayo egoqa ngokuzenzakalelayo endaweni lg
yokuphumula (enkulu).
Lesi sibonelo sisebenzisa umbala ( bg-light
) kanye nesikhala ( my-2
, my-lg-0
, mr-sm-0
, my-sm-0
) amakilasi awusizo.
Ibhrendi
I- .navbar-brand
elekthronikhi ingasetshenziswa kuma-elementi amaningi, kodwa ihange lisebenza kangcono njengoba ezinye izici zingase zidinge amakilasi osizo noma izitayela zangokwezifiso.
Ukwengeza izithombe kuhlelo .navbar-brand
cishe kuzodinga izitayela zangokwezifiso noma izinsiza ukuze usayizi ofanele. Nazi ezinye izibonelo zokubonisa.
Nav
Izixhumanisi zokuzulazula ze-Navbar zakhela phezu .nav
kwezinketho zethu ngesigaba sazo sokuguqula futhi zidinga ukusetshenziswa kwamakilasi e-toggler ukuthola isitayela esifanele sokuphendula. Ukuzulazula kuma-navbar nakho kuzokhula kuthathe indawo evundlile ngangokunokwenzeka ukuze ugcine okuqukethwe kwakho kwe-navbar kuhambisana ngokuphephile.
Izimo ezisebenzayo-nge .active
--ukukhombisa ikhasi lamanje kungasetshenziswa ngokuqondile ku- .nav-link
s noma umzali wabo oseduze .nav-item
.
Futhi ngenxa yokuthi sisebenzisa amakilasi kuma-navs ethu, ungagwema indlela esuselwe ohlwini ngokuphelele uma uthanda.
Ungasebenzisa futhi okwehliswayo ku-navbar yakho nav. Amamenyu okudonsela phansi adinga into yokugoqa ukuze ibekwe, ngakho-ke qiniseka ukuthi usebenzisa izinto ezihlukene nezibekwe esidlekeni .nav-item
futhi .nav-link
njengoba kukhonjisiwe ngezansi.
Beka izilawuli zamafomu ahlukahlukene kanye nezingxenye ngaphakathi kwe-navbar nge- .form-inline
.
Izinto ezisheshayo zezingane .navbar
ekusetshenzisweni kwesakhiwo esiguqukayo futhi zizozenzakalela zibe justify-content: space-between
. Sebenzisa izinsiza ezengeziwe eziguquguqukayo njengoba kudingeka ukuze ulungise lokhu kuziphatha.
Amaqembu okokufaka ayasebenza, nawo:
Izinkinobho ezahlukahlukene zisekelwa njengengxenye yalawa mafomu e-navbar, nawo. Lesi futhi isikhumbuzo esihle sokuthi izinsiza zokuqondanisa okume mpo zingasetshenziswa ukuqondisa izinto ezinosayizi abahlukahlukene.
Umbhalo
Ama-Navbar angase aqukathe izingcezu zombhalo ngosizo lwe- .navbar-text
. Leli klasi lilungisa ukuqondanisa okume mpo kanye nesikhala esivundlile seyunithi yezinhlamvu zombhalo.
Hlanganisa futhi uhlanganise nezinye izingxenye kanye nezinsiza njengoba kudingeka.
Izikimu zombala
Ukwenza i-navbar akukaze kube lula ngenxa yenhlanganisela yamakilasi etimu background-color
nezinsiza. Khetha kuzo .navbar-light
ukuze usebenzise ngemibala engemuva ekhanyayo, noma .navbar-dark
ngemibala engemuva emnyama. Bese, yenza ngendlela oyifisayo .bg-*
nezinsiza.
Izitsha
Nakuba kungadingeki, ungakwazi ukugoqa ibha ye-navbar .container
ukuze uyibeke maphakathi nekhasi noma wengeze eyodwa phakathi ukuze ubeke phakathi kuphela okuqukethwe kwe- navbar ephezulu emile noma engashintshi .
Uma isiqukathi singaphakathi kwe-navbar yakho, i-padding yaso evundlile iyasuswa ezindaweni zokuphumula ezingaphansi .navbar-expand{-sm|-md|-lg|-xl}
kwesigaba sakho esicacisiwe. Lokhu kuqinisekisa ukuthi asiphindaphindi kabili ekuphedeni kungenasidingo ezimbotsheni zokubuka eziphansi uma ibha yakho ye-navbar igoqiwe.
Ukubekwa
Sebenzisa izinsiza zethu zesikhundla ukubeka ama-navbar ezindaweni ezingamile. Khetha kusukela kokugxilile kuye phezulu, okugxilwe phansi, noma kunamathele phezulu (skrola ngekhasi kuze kube yilapho lifika phezulu, bese lihlala lapho). Ama-navbar angashintshi asebenzisa position: fixed
, okusho ukuthi adonswa ekugelezeni okuvamile kwe-DOM futhi angase adinge i-CSS yangokwezifiso (isb., padding-top
ku- <body>
) ukuze kuvinjelwe ukugqagqana nezinye izici.
Futhi qaphela ukuthi .sticky-top
isebenzisa position: sticky
, okungasekelwe ngokugcwele kuso sonke isiphequluli .
Ukuziphatha okusabelayo
Ama-Navbar angasebenzisa .navbar-toggler
, .navbar-collapse
, kanye .navbar-expand{-sm|-md|-lg|-xl}
namakilasi ukuze ashintshe lapho okuqukethwe kwawo kugoqeka ngemva kwenkinobho. Ngokuhambisana nezinye izinsiza, ungakhetha kalula ukuthi uzibonisa nini noma uzifihle nini izinto ezithile.
Kuma-navbar angawi, engeza .navbar-expand
iklasi ku-navbar. Kuma-navbar ahlala egoqa, ungangezi noma yisiphi .navbar-expand
isigaba.
I-Toggler
Iziguquli zebha ye-Navbar ziqondaniswe kwesokunxele ngokuzenzakalelayo, kodwa uma zilandela i-elementi eyizelamani njenge- , zizoqondaniswa .navbar-brand
ngokuzenzakalelayo kwesokudla. Ukubuyisela emuva imakhaphu yakho kuzohlehlisa ukubekwa kwesiguquli. Ngezansi kunezibonelo zezitayela ezahlukene zokuguqula.
Ngaphandle .navbar-brand
kokuboniswa kuphoyinti eliphansi kakhulu:
Ngegama lomkhiqizo eliboniswa kwesokunxele kanye ne-toggler kwesokudla:
Nge-toggler kwesokunxele kanye negama lomkhiqizo kwesokudla:
Okuqukethwe kwangaphandle
Kwesinye isikhathi ufuna ukusebenzisa i-plugin yokugoqa ukuze uqalise okuqukethwe okufihliwe kwenye indawo ekhasini. Ngoba i-plugin yethu isebenza ekufaniseni id
, data-target
lokho kwenziwa kalula!
Collapsed content
Toggleable via the navbar brand.