Xiphepherhele xa swiphepherhele
Hi ku tisungulela pfuxeta ku famba-famba ka Bootstrap kumbe ku xaxameta swiphemu swa ntlawa hi ku ya hi xiyimo xa ku rhendzeleka ku kombisa leswaku hi xihi xihlanganisi lexi tirhaka sweswi eka xivono.
Scrollspy yi na swilaveko swi nga ri swingani leswaku yi tirha kahle:
- Loko u aka JavaScript ya hina ku suka eka xihlovo, swi lava
util.js
. - Yi fanele ku tirhisiwa eka xiphemu xa nav xa Bootstrap kumbe ntlawa wa nxaxamelo .
- Scrollspy yi lava
position: relative;
eka elemente leyi u yi hlotaka, hi ntolovelo<body>
. - Loko u hlota swiaki swin’wana handle ka
<body>
, tiyiseka leswaku u niheight
sete ni kuoverflow-y: scroll;
tirhisiwa. - Tianchor (
<a>
) ta laveka naswona ti fanele ku kombetela eka elemente leyi nga na sweswoid
.
Loko yi tirhisiwile hi ndlela leyi humelelaka, ntlawa wa wena wa nav kumbe wa nxaxamelo wu ta pfuxeta hi ku landza sweswo, wu rhurhela .active
tlilasi ku suka eka nchumu wun’wana ku ya eka wun’wana hi ku ya hi swikongomelo swa wona leswi fambisanaka na swona.
Skrolela ndhawu leyi nga ehansi ka navbar ivi u hlalela ku cinca ka tlilasi leyi tirhaka. Swilo leswi nga ehansi swi ta kombisiwa na swona.
@mafurha
Ad leggings keytar, brunch id vutshila nkhuvo dolor labore. Pitchfork yr enim lo-fi va nga si xavisa qui. Tumblr timfanelo ta xikanyakanya xa purasi ku ya etafuleni whatever. Anim keffiyeh xitsonga xitsonga xitsonga xitsonga xitsonga. Velit seitan mcsweeney's xifaniso xa xiyindlwana 3 mpfundla n'weti irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui kumbexana a wu se twa hi vona et cardigan nkwama wa vutshembeki culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred xihlekiso biodiesel keffiyeh mutirhi wa mavoko ullamco consequat.
@mdo
Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork beard. Freegan beard aliqua cupidatat mcsweeney's vero. Cupidatat four loko nisi, ea helvetica nulla carles. Tattooed cosby sweater food truck, mcsweeney's quis non freegan vinyl. Lo-fi wes anderson +1 sartorial. Carles non aesthetic exercitation quis gentrify. Brooklyn adipisicing craft beer vice keytar deserunt.
one
Occaecat commodo aliqua delectus. Fap craft beer deserunt skateboard ea. Lomo bicycle rights adipisicing banh mi, velit ea sunt next level locavore single-origin coffee in magna veniam. High life id vinyl, echo park consequat quis aliquip banh mi pitchfork. Vero VHS est adipisicing. Consectetur nisi DIY minim messenger bag. Cred ex in, sustainable delectus consectetur fanny pack iphone.
two
In incididunt echo park, officia deserunt mcsweeney's proident master cleanse thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1 biodiesel laborum craft beer. Single-origin coffee wayfarers irure four loko, cupidatat terry richardson master cleanse. Assumenda you probably haven't heard of them art party fanny pack, tattooed nulla cardigan tempor ad. Proident wolf nesciunt sartorial keffiyeh eu banh mi sustainable. Elit wolf voluptate, lo-fi ea portland before they sold out four loko. Locavore enim nostrud mlkshk brooklyn nesciunt.
three
Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
Keytar twee blog, culpa nkwama wa murhumiwa marfa yini na yini delectus lori ya swakudya. Sapiente synth id ya ku ehleketa. Locavore sed helvetica cliche irony, ti thundercats kumbexana a wu si twa hi tona consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat va nga si xavisiwa, terry richardson proident brunch nesciunt quis cosby xisuti pariatur keffiyeh ut helvetica mutirhi wa mavoko. Cardigan craft biya seitan yi lunghekile velit. VHS chambray laboris xitsongwatsongwana xa nkarhinyana. Anim mollit minim commodo ullamco switsongwatsongwana swa ku dzindza ka tilo.
Scrollspy yi tlhela yi tirha na nested .nav
s. Loko nested .nav
yi ri .active
, vatswari va yona na vona va ta va .active
. Skrolela ndhawu leyi nga ekusuhi na navbar ivi u hlalela ku cinca ka tlilasi leyi tirhaka.
Nchumu wa 1
Ex consequat commodo adipisicing ku endla vutiolori aute handle ka occaecat ullamco duis aliqua id magna ullamco eu. Endla aute ipsum ipsum ullamco cillum consectetur ut na ku tirha hi ku landzelelana. Fugiat laborum incididunt nkarhinyana eu vuyelo enim dolore proident. qui laborum do non excepteur nulla magna eiusmod consecteturt in. aliqua et aliqua ya fis et incididunt voluptate non anim reprehenderit adipisicing dolore ut consequat deserunt mollit dolore. Aliquip nulla enim veniam non fugiat id xitombo xa xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga
Nchumu wa 1-1
Amet tempor mollit aliquip pariatur handle ka comodo endla ea cillum commodo Lorem na occaecat elit qui et. Aliquip ntirho ex ex esse voluptate occaecat Lorem ullamco xikwembu xa xirhendzevutani. Aliqua cillum excepteur irure vuyelo bya xiyimo xa le henhla id quis ea. Tshama proident ullamco aute magna pariatur ku tirha hi nomu. Reprehenderit aliqua commodo eiusmod aliquip est do duis amet proident magna consectetur consequat eu xikweleti lexi balekeke lexi nga riki xinene. Enim aliquip ku endla vutiolori ullamco adipisicing voluptate excepteur ku endla vutiolori lebyintsongo lebyintsongo bya commodo ku endla vutiolori officia nisi adipisicing. Anim id duis qui consequat ku tirha ntirho wo adipisicing sint dolor elit cillum anim na ku baleka.
Nchumu wa 2-2
Cillum nisi deserunt magna eiusmod qui eiusmod velit voluptate pariatur laborum sunt enim. Irure laboris mollit consequat incididunt sint et culpa culpa incididunt adipisicing magna magna occaecat. Nulla ipsum cillum eiusmod sint elit excepteur ea labore enim consectetur in labore anim. Proident ullamco ipsum esse elit ut Lorem eiusmod dolor et eiusmod. Anim occaecat nulla in non consequat eiusmod velit incididunt.
Item 2
Quis magna Lorem anim amet ipsum do mollit sit cillum voluptate ex nulla tempor. Laborum consequat non elit enim exercitation cillum aliqua consequat id aliqua. Esse ex consectetur mollit voluptate est in duis laboris ad sit ipsum anim Lorem. Incididunt veniam velit elit elit veniam Lorem aliqua quis ullamco deserunt sit enim elit aliqua esse irure. Laborum nisi sit est tempor laborum mollit labore officia laborum excepteur commodo non commodo dolor excepteur commodo. Ipsum fugiat ex est consectetur ipsum commodo tempor sunt in proident.
Item 3
Quis anim sit do amet fugiat dolor velit sit ea ea do reprehenderit culpa duis. Nostrud aliqua ipsum fugiat minim proident occaecat excepteur aliquip culpa aute tempor reprehenderit. Deserunt tempor mollit elit ex pariatur dolore velit fugiat mollit culpa irure ullamco est ex ullamco excepteur.
Item 3-1
Deserunt quis elit Lorem eiusmod amet enim enim amet minim Lorem proident nostrud. Ea id dolore anim exercitation aute fugiat labore voluptate cillum do laboris labore. Ex velit exercitation nisi enim labore reprehenderit labore nostrud ut ut. Esse officia sunt duis aliquip ullamco tempor eiusmod deserunt irure nostrud irure. Ullamco proident veniam laboris ea consectetur magna sunt ex exercitation aliquip minim enim culpa occaecat exercitation. Est tempor excepteur aliquip laborum consequat do deserunt laborum esse eiusmod irure proident ipsum esse qui.
Item 3-2
Labore tshama culpa commodo elit adipisicing tshama aliquip elit proident voluptate minim mollit nostrud aute ku sola ku endla. Mollit excepteur eu Lorem ipsum anim commodo sint ntirho Lorem eka ku endla vutiolori velit incididunt. Occaecat consectetur nisi eka occaecat proident minim enim sunt ku sola ku endla vutiolori cupidatat et do officia. Aliquip consequat ad ku tirha ntirho wo tirha mollit ut amet. Tshama pariatur nkarhinyana proident eka veniam culpa aliqua handle ka elit magna fugiat eiusmod amet officia.
Scrollspy yi tlhela yi tirha na .list-group
s. Skrolela ndhawu leyi nga ekusuhi ni ntlawa wa nxaxamelo ivi u hlalela ku cinca ka tlilasi leyi tirhaka.
Nchumu wa 1
Ex consequat commodo adipisicing ku endla vutiolori aute handle ka occaecat ullamco duis aliqua id magna ullamco eu. Endla aute ipsum ipsum ullamco cillum consectetur ut na ku tirha hi ku landzelelana. Fugiat laborum incididunt nkarhinyana eu vuyelo enim dolore proident. qui laborum do non excepteur nulla magna eiusmod consecteturt in. aliqua et aliqua ya fis et incididunt voluptate non anim reprehenderit adipisicing dolore ut consequat deserunt mollit dolore. Aliquip nulla enim veniam non fugiat id xitombo xa xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga xitsonga
Nchumu wa 2
Quis magna Lorem anim amet ipsum endla mollit tshama cillum voluptate ex nulla nkarhinyana. Laborum consequat non elit enim ku endla vutiolori cillum aliqua vuyelo bya id aliqua. Esse ex consectetur mollit voluptate est eka ntirho wa ku tirha ad sit ipsum anim Lorem. Incididunt veniam velit elit elit veniam Lorem aliqua quis ullamco deserunt tshama enim elit aliqua esse irure. Laborum nisi sit est ntirho wa nkarhinyana mollit ntirho officia ntirho excepteur commodo non commodo dolor handle ka commodo. Ipsum fugiat ex est consectetur ipsum commodo nkarhi wo leha sunt eka proident.
Nchumu wa 3
Quis anim tshama do amet fugiat dolor velit tshama ea ea endla ku sola culpa duis. Nostrud aliqua ipsum fugiat minim proident occaecat handle ka xitsongwatsongwana xa xirhendzevutani xa ku sola ka nkarhinyana. Deserunt tempor mollit elit ex pariatur dolore velit ku baleka xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo.
Nchumu wa 4
Quis anim tshama do amet fugiat dolor velit tshama ea ea endla ku sola culpa duis. Nostrud aliqua ipsum fugiat minim proident occaecat handle ka xitsongwatsongwana xa xirhendzevutani xa ku sola ka nkarhinyana. Deserunt tempor mollit elit ex pariatur dolore velit ku baleka xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo xa xitombo.
Ku engetela hi ku olova mahanyelo ya scrollspy eka ku famba-famba ka wena ka topbar, engetela data-spy="scroll"
eka elemente leyi u lavaka ku hlota eka yona (hi ntolovelo leswi swi ta va swi ri <body>
). Kutani engetela data-target
xihlawulekisi hi ID kumbe tlilasi ya elemente ya mutswari ya xiphemu xihi na xihi .nav
xa Bootstrap.
Endzhaku ko engetela position: relative;
eka CSS ya wena, vitana scrollspy hi ku tirhisa JavaScript:
Swikongomiso swa ID leswi nga lulamisiwaka swa laveka
Swihlanganisi swa Navbar swi fanele ku va na swikongomelo swa id leswi nga lulamisiwaka. Xikombiso, a yi <a href="#home">home</a>
fanele ku fambisana na nchumu wo karhi eka DOM ku fana na <div id="home"></div>
.
Swiaki leswi nga riki :visible
swa xikongomelo swi honisiwile
Swiaki leswi kongomisiweke leswi nga riki :visible
hi ku ya hi jQuery swi ta honisiwa naswona swilo swa swona swa nav leswi fambelanaka a swi nge pfuki swi kombisiwile.
Loko u tirhisa scrollspy hi ku fambisana na ku engetela kumbe ku susa swiaki eka DOM, u ta lava ku vitana ndlela yo pfuxeta ku fana na sweswo:
Ku herisa scrollspy ya elemente.
Swihlawulekisi swi nga hundzisiwa hi ku tirhisa swihlawulekisi swa data kumbe JavaScript. Eka swihlawulekisi swa datha, engetela vito ra xihlawuhlawu eka data-
, tanihi le ka data-offset=""
.
Vito | Muxaka | Ku tlula | Nhlamuselo |
---|---|---|---|
offset | nomboro | 10. | Tipikseli to offset kusuka ehenhla loko u hlayela xiyimo xa scroll. |
Muxaka wa Xiendlakalo | Nhlamuselo |
---|---|
ku tirhisa.bs.scrollspy | Xiendlakalo lexi xi pfurha eka elemente ya scroll nkarhi wun’wana na wun’wana loko nchumu lowuntshwa wu sungula ku tirhisiwa hi scrollspy. |