Dokumɛnt ɛn ɛgzampul fɔ Bootstrap in pawaful, rispɔnsiv nevigishɔn hεda, di navbar. Inklud sɔpɔt fɔ branding, nevigishɔn, ɛn ɔda tin dɛn, inklud sɔpɔt fɔ wi kollaps plɔgin.
Aw i de wok
Na dis na wetin yu nid fɔ no bifo yu bigin wit di navbar:
Navbars nid wan wrapping .navbarwit .navbar-expand{-sm|-md|-lg|-xl}fɔ rispɔnsiv kollaps ɛn kala skim klas dɛn.
Navbars ɛn dɛn kɔntinyu na fluid bay difɔlt. Yuz kɔntena dɛn we yu kin pik fɔ stɔp dɛn ɔrizɔntal wit.
Yuz wi spays ɛn fleks yutiliti klas fɔ kɔntrol spɛshal ɛn alaynɛshɔn insay navbar dɛn.
Navbar dɛn kin ansa bay difɔlt, bɔt yu kin izi fɔ chenj dɛn fɔ chenj dat. Rispɔnsiv bihayvya dipen pan wi Kɔlaps JavaSkript plɔgin.
Navbar dɛn de ayd bay difɔlt we dɛn de print. Fos dɛn fɔ print bay we yu ad .d-printdi .navbar. Si di displei yutiliti klas.
Mek shɔ se yu gɛt akses bay we yu yuz wan <nav>ɛlimɛnt ɔ, if yu de yuz wan mɔ jenɛrik ɛlimɛnt lɛk a <div>, ad a role="navigation"to ɛvri navbar fɔ mek yu no klia wan se na landmak rijyɔn fɔ di wan dɛn we de yuz ɛp tɛnkɔlɔji dɛn.
.navbar-togglerfɔ yuz wit wi kollaps plɔgin ɛn ɔda nevigishɔn tɔglin bihayvya dɛn.
.form-inlinefɔ ɛni fɔm kɔntrol ɛn akshɔn dɛn.
.navbar-textfɔ ad string dɛn we gɛt tɛks we gɛt vertikal sɛnt.
.collapse.navbar-collapsefɔ grup ɛn ayd navbar kɔntinyu bay wan mama ɛn papa brekpɔynt.
Na dis na wan ɛgzampul fɔ ɔl di sab-kɔmpɔnɛnt dɛn we de insay wan rispɔnsiv layt-tim navbar we de kɔlaps ɔtomɛtik wan na di lg(big) brekpɔynt.
Dis ɛgzampul de yuz kɔlɔ ( bg-light) ɛn spɛshal ( my-2, my-lg-0, mr-sm-0, my-sm-0) yutiliti klas dɛn.
Mak
Di .navbar-brandkin aplay to mɔs ɛlimɛnt dɛn, bɔt wan ankɔ de wok fayn as sɔm ɛlimɛnt dɛn kin nid yutiliti klas ɔ kɔstɔm stayl dɛn.
If yu ad pikchɔ dɛn to di .navbar-brand, i go mɔs bi se ɔltɛm yu nid kɔstɔm stayl ɔ yutiliti dɛn fɔ mek dɛn saiz fayn fayn wan. Na sɔm ɛgzampul dɛn ya fɔ sho.
Nav
Navbar nevigishɔn link dɛn bil pan wi .navopshɔn dɛn wit dɛn yon modifya klas ɛn dɛn nid fɔ yuz toggler klas dɛn fɔ mek dɛn stayl di rayt we fɔ ansa. Nevigishɔn insay navbar dɛn go gro bak fɔ tek bɔku ɔrizɔntal spɛs as pɔsibul fɔ kip yu navbar kɔntinyu dɛn alaynɛd fayn fayn wan.
Aktiv stet dɛn—wit .active—fɔ sho di pej we de naw kin aplay dairekt to .nav-links ɔ dɛn mama ɛn papa we de nia .nav-itemdɛn s.
Ɛn bikɔs wi de yuz klas fɔ wi nav dɛn, yu kin avɔyd di list-based aprɔch ɔltogɛda if yu want.
Yu kin yuz drɔpdɔwn dɛn bak na yu navbar nav. Drɔpdɔwn mɛnyu dɛn nid fɔ rap ɛlimɛnt fɔ posishun, so mek shɔ se yu yuz sɛpret ɛn nɛst ɛlimɛnt dɛn fɔ .nav-itemɛn .nav-linklɛk aw dɛn sho dɔŋ ya.
Fɔm dɛn
Put difrɛn fɔm kɔntrol ɛn kɔmpɔnɛnt dɛn insay wan navbar wit .form-inline.
Wantɛm pikin dɛn ɛlimɛnt dɛn we de .navbaryuz fleks layout ɛn go difɔlt to justify-content: space-between. Yuz ɔda fleks yutiliti dɛn as nid de fɔ ajɔst dis bihayvya.
Input grup dɛn de wok, dɛnsɛf:
Difrɛn bɔtin dɛn de sɔpɔt as pat pan dɛn navbar fɔm dɛn ya, bak. Dis na big mɛmba bak se dɛn kin yuz vertikal alaynɛshɔn yutiliti fɔ alaynɛd difrɛn saiz ɛlimɛnt dɛn.
Tɛks
Navbar dɛn kin gɛt bit dɛn fɔ tɛks wit di ɛp we .navbar-text. Dis klas de ajɔst vertikal alaynɛshɔn ɛn ɔrizɔntal spɛshal fɔ string dɛn na tɛks.
Miks ɛn mach wit ɔda kɔmpɔnɛnt ɛn yutiliti dɛn as nid de.
Kɔlɔ skim dɛn
Tim di navbar nɔ ɛva izi tank to di kɔmbaynshɔn fɔ tim klas ɛn background-coloryutiliti. Pik frɔm .navbar-lightfɔ yuz wit layt bakgrɔn kɔlɔ dɛn, ɔ .navbar-darkfɔ dak bakgrɔn kɔlɔ dɛn. Dɔn, kɔstɔmayt wit .bg-*yutiliti dɛn.
Kɔntena dɛn
Pan ɔl we i nɔ nid, yu kin rap wan navbar insay a .containerfɔ sɛnt am na wan pej ɔ ad wan insay fɔ jɔs sɛnt di tin dɛn we de insay wan fiks ɔ statik tɔp navbar .
We di kɔntena de insay yu navbar, dɛn kin pul in ɔrizɔntal pad na di brek pɔynt dɛn we smɔl pas di .navbar-expand{-sm|-md|-lg|-xl}klas we yu dɔn spɛsifa. Dis de mek shɔ se wi nɔ de dubl ɔp pan padding we nɔ nid fɔ de pan lɔwa viupɔt dɛn we yu navbar dɔn kol.
Di ples we dɛn fɔ put am
Yuz wi pozishɔn yutiliti fɔ put navbar dɛn na nɔ-statik pozishɔn dɛn. Pik frɔm fiks to di ɔp, fiks to di bɔt, ɔ stik to di ɔp (skrol wit di pej te i rich ɔp, dɔn i de de). Fiks navbar dɛn de yuz position: fixed, we min se dɛn pul dɛn frɔm di nɔmal flɔ na di DOM ɛn dɛn kin nid kɔstɔm CSS (ɛgz., padding-topna di <body>) fɔ mek dɛn nɔ ɔvalap wit ɔda ɛlimɛnt dɛn.
Navbars kin yuz .navbar-toggler, .navbar-collapse, ɛn .navbar-expand{-sm|-md|-lg|-xl}klas fɔ chenj we dɛn kɔntinyu fɔ kol biɛn wan bɔtin. We yu jɔyn wit ɔda yutiliti dɛn, yu kin pik izi wan ustɛm fɔ sho ɔ ayd patikyula tin dɛn.
Fɔ navbar dɛn we nɔ de ɛva kɔlap, ad di .navbar-expandklas na di navbar. Fɔ navbar dɛn we kin ɔltɛm kol, nɔ ad ɛni .navbar-expandklas.
Toggler fɔ di wan dɛn we de chenj
Navbar togglers na lef-alayn bay difɔlt, bɔt if dɛn fala wan brɔda ɛn sista ɛlimɛnt lɛk wan .navbar-brand, dɛn go ɔtomɛtik alaynɛd to di fa rayt. We yu rivɛns yu mak, i go rivɛns di ples we dɛn put di tɔgl. Dis dɔŋ ya na ɛgzampul dɛn bɔt difrɛn stayl dɛn we dɛn kin yuz fɔ tɔgl.
Wit no .navbar-brandsho in lowest brekpoint:
Wit wan brand nem we dɛn sho na di lɛft ɛn toggler na di rayt say:
Wit wan toggler na di lef ɛn brand nem na di rayt:
Di tin dɛn we de na do
Sɔntɛnde, yu kin want fɔ yuz di kɔlaps plɔgin fɔ mek yu gɛt tin dɛn we yu ayd ɔdasay na di pej. Bikɔs wi plɔgin de wok pan di idɛn data-targetmaching, dat kin izi fɔ du!