Carousel
He waahanga whakaatakiriata mo te eke paihikara i roto i nga huānga—whakaahua, kiriata ranei o te tuhinga—penei i te carousel.
Ko te carousel he whakaatakiriata mo te eke paihikara i roto i te raupapa o nga ihirangi, i hangaia me nga huringa CSS 3D me tetahi waahanga JavaScript. Ka mahi me te raupapa whakaahua, tuhinga, tohu tohu ritenga ranei. Kei roto hoki te tautoko mo nga mana whakahaere me nga tohu o mua/muri.
I roto i nga kaitirotiro kei te tautokohia te API Tirohanga Whārangi , ka kore te carousel e paheke ina kore te wharangi paetukutuku e kitea e te kaiwhakamahi (penei i te wa e hohekore ana te ripa tirotiro, ka whakaitihia te matapihi tirotiro, me etahi atu).
Kia mohio koe kaore i te tautokohia nga carousels kohanga, karekau hoki nga carousels e tau ana ki nga paerewa urunga.
Ka mutu, mena kei te hanga koe i to maatau JavaScript mai i te puna, meutil.js
.
Ko nga carousels e kore e whakarite aunoa i nga rahi kiriata. Na tenei, ka hiahia pea koe ki te whakamahi i etahi atu taputapu, momo ritenga ranei kia tika te rahi o nga ihirangi. Ahakoa e tautoko ana nga carousels i nga mana me nga tohu o mua/panuku, kaore e tino hiahiatia ana. Tāpirihia me te whakarite kia rite ki taau e pai ai.
Me whakarite he id ahurei ki runga .carousel
mo nga mana whiriwhiri, ina koa kei te whakamahi koe i nga carousels maha i runga i te wharangi kotahi.
Anei he carousel me nga kiriata anake. Kia mahara ki te noho o nga whakaahua carousel .d-block
me .img-fluid
runga ki te aukati i te tirohanga atahanga taunoa.
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="..." alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="..." alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="..." alt="Third slide">
</div>
</div>
</div>
Te taapiri i nga mana o mua me muri:
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="..." alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="..." alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="..." alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Ka taea hoki te taapiri i nga tohu ki te carousel, ki te taha o nga mana whakahaere.
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="..." alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="..." alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="..." alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Ko te huānga hohe tuatahi e hiahiatia ana
Me whakauru te .active
akomanga ki tetahi o nga kiriata. Ki te kore, ka kore te carousel e kitea.
Tāpiri tapanga ki o kiriata me te .carousel-caption
huānga i roto i tetahi .carousel-item
. Ka taea te huna i runga i nga tauranga tiro iti ake, penei i raro nei, me nga taputapu whakaatu . Ka huna e matou i te tuatahi me .d-none
te whakahoki mai i runga i nga taputapu reo-rahi me te .d-md-block
.
Whakamahia nga huanga raraunga kia ngawari te whakahaere i te tuunga o te carousel. data-slide
ka whakaae ki nga kupumatua prev
, next
, e whakarereke ana i te tuunga kiriata e pa ana ki tona turanga o naianei. Arā, whakamahia data-slide-to
ki te tuku i te taupū kiriata mata ki te carousel data-slide-to="2"
, ka huri i te tūnga kiriata ki tetahi taupū ka timata ki te 0
.
Ka data-ride="carousel"
whakamahia te huanga ki te tohu i te carousel hei whakaohooho timata mai i te utaina o te wharangi. Kaore e taea te whakamahi me te (he nui me te kore e tika) te arawhiti JavaScript o taua carousel.
Waea a ringatia te carousel me:
Ko nga whiringa ka taea te tuku ma nga huanga raraunga, JavaScript ranei. Mo nga huanga raraunga, apitihia te ingoa whiringa ki data-
, penei i te data-interval=""
.
Ingoa | Momo | Taunoa | Whakaahuatanga |
---|---|---|---|
wā | tau | 5000 | Te nui o te wa ki te whakaroa i waenga i te paihikara aunoa i tetahi mea. Mena he teka, e kore e huri aunoa a carousel. |
papapātuhi | boolean | pono | Mena ka tauhohe te carousel ki nga takahanga papapātuhi. |
okioki | aho | boolean | "whakapapa" | Ki te tautuhia ki te I runga i nga taputapu pa-whakahohea, ina tautuhia ki te |
ekenga | aho | teka | Ka purei aunoa i te carousel i muri i te huringa a te kaiwhakamahi i te mea tuatahi. Mena "carousel", ka purei aunoa i te carousel i runga i te uta. |
takai | boolean | pono | Mena ka huri haere tonu te carousel, me kaha ranei te aukati. |
Nga tikanga tukutahi me nga whakawhitinga
Ko nga tikanga API katoa he tukutahi ka timata te whakawhiti . Ka hoki mai ano ki te kaikaranga ina timata te whakawhiti engari i mua i te mutunga . I tua atu, ka warewarehia te karanga tikanga mo tetahi waahanga whakawhiti .
Ka arataki i te carousel me etahi whiringa object
ka tiimata ka timata te paihikara i roto i nga taonga.
Ka huri i nga taonga carousel mai i te maui ki te matau.
Ka aukati te carousel i te eke paihikara ma nga taonga.
Cycles the carousel to a particular frame (0 based, similar to an array). Returns to the caller before the target item has been shown (i.e. before the slid.bs.carousel
event occurs).
Cycles to the previous item. Returns to the caller before the previous item has been shown (i.e. before the slid.bs.carousel
event occurs).
Cycles to the next item. Returns to the caller before the next item has been shown (i.e. before the slid.bs.carousel
event occurs).
Destroys an element’s carousel.
Bootstrap’s carousel class exposes two events for hooking into carousel functionality. Both events have the following additional properties:
direction
: The direction in which the carousel is sliding (either"left"
or"right"
).relatedTarget
: Ko te huānga DOM kei te reheke ki te waahi hei taonga hohe.from
: Te taupū o te tūemi o nāianeito
: Te taupū o te tūemi e whai ake nei
Ko nga huihuinga carousel katoa ka pupuhihia ki te carousel ake (arā, ki te <div class="carousel">
).
Momo Takahanga | Whakaahuatanga |
---|---|
slide.bs.carousel | Ka puhipuhi tonu tenei takahanga ina ka tonohia te slide aratuka tauira. |
slid.bs.carousel | Ka pupuhihia tenei takahanga ina oti ana te carousel i tana whakawhiti kiriata. |