Carousel
He kiʻi kiʻi kiʻi no ka holo kaʻa ʻana ma waena o nā mea—nā kiʻi a i ʻole nā paheʻe kikokikona—e like me ka carousel.
ʻO ka carousel kahi kiʻi kiʻiʻoniʻoni no ka holo kaʻa ʻana ma o ke ʻano o ka ʻike, i kūkulu ʻia me CSS 3D transforms a me kahi mea JavaScript. Hoʻohana ia me nā kiʻi, kikokikona, a i ʻole markup maʻamau. Loaʻa pū kekahi i ke kākoʻo no nā mana mua / aʻe a me nā hōʻailona.
Ma nā polokalamu kele pūnaewele kahi i kākoʻo ʻia ai ka API Visibility ʻAoʻao , e pale ka carousel i ka paheʻe ʻana ke ʻike ʻole ʻia ka ʻaoʻao pūnaewele e ka mea hoʻohana (e like me ka wā ʻaʻole hoʻohana ʻia ka ʻaoʻao polokalamu kele pūnaewele, hoʻemi ʻia ka puka aniani, etc.).
E ʻoluʻolu e hoʻomaopopo ʻaʻole kākoʻo ʻia nā carousels pūnana, a ʻaʻole kūlike nā carousels i nā kūlana hiki ke loaʻa.
ʻO ka hope, inā ʻoe e kūkulu nei i kā mākou JavaScript mai ke kumu, ponoutil.js
ia .
ʻAʻole hana maʻamau nā Carousels i nā ana paheʻe. No laila, pono paha ʻoe e hoʻohana i nā pono hana hou a i ʻole nā ʻano maʻamau i ka nui o ka ʻike. ʻOiai ke kākoʻo nei nā carousels i nā mana a me nā hōʻailona o mua/hope aku, ʻaʻole koi ʻia lākou. Hoʻohui a hoʻopilikino e like me kou manaʻo pono.
E hoʻonohonoho i kahi id kū hoʻokahi ma ka .carousel
no nā mana koho, ʻoi aku ka nui inā hoʻohana ʻoe i nā carousels he nui ma ka ʻaoʻao hoʻokahi.
Eia kahi carousel me nā paheʻe wale nō. E hoʻomaopopo i ka loaʻa ʻana o nā kiʻi carousel .d-block
a .img-fluid
ma luna o nā kiʻi carousel e pale ai i ka hoʻolikelike kiʻi paʻamau.
<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>
Hoʻohui i nā mana mua a me nā mea hou aʻe:
<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>
Hiki iā ʻoe ke hoʻohui i nā hōʻailona i ka carousel, me ka ʻaoʻao o nā mana.
<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>
Pono ka mea hana mua
Pono .active
e hoʻohui ʻia ka papa i kekahi o nā paheʻe. A i ʻole, ʻaʻole ʻike ʻia ka carousel.
Hoʻohui maʻalahi i nā huaʻōlelo i kāu mau paheʻe me ka .carousel-caption
mea i loko o kekahi .carousel-item
. Hiki iā lākou ke hūnā maʻalahi ma nā wahi nānā liʻiliʻi, e like me ka mea i hōʻike ʻia ma lalo nei, me nā pono hōʻike koho . Huna mua mākou iā lākou .d-none
me ka hoʻihoʻi ʻana iā lākou ma nā hāmeʻa liʻiliʻi me .d-md-block
.
E hoʻohana i nā hiʻohiʻona ʻikepili e hoʻomalu maʻalahi i ke kūlana o ka carousel. data-slide
ʻae i nā huaʻōlelo a i prev
ʻole next
, e hoʻololi i ke kūlana paheʻe e pili ana i kona kūlana i kēia manawa. ʻO kahi ʻē aʻe, e hoʻohana data-slide-to
i ka hāʻawi ʻana i kahi papa kuhikuhi paheʻe maka i ka carousel data-slide-to="2"
, e hoʻololi i ke kūlana paheʻe i kahi kuhikuhi kikoʻī e hoʻomaka ana me 0
.
Hoʻohana data-ride="carousel"
ʻia ka ʻano e hōʻailona ai i kahi carousel ma ke ʻano he animating e hoʻomaka ana ma ka hoʻouka ʻana i ka ʻaoʻao. ʻAʻole hiki ke hoʻohana pū ʻia me (nui a pono ʻole) ka hoʻomaka mua ʻana o JavaScript o ka carousel like.
Kāhea lima ʻia ka carousel me:
Hiki ke hāʻawi ʻia nā koho ma o nā ʻikepili a i ʻole JavaScript. No nā ʻano ʻikepili, e hoʻopili i ka inoa koho i data-
, e like me ka data-interval=""
.
inoa | ʻAno | Default | wehewehe |
---|---|---|---|
waena | helu | 5000 | ʻO ka nui o ka manawa e hoʻopaneʻe ai ma waena o ke kaʻa ʻakomi i kahi mea. Inā hoʻopunipuni, ʻaʻole e holo ʻokoʻa ka carousel. |
keyboard | boolean | ʻoiaʻiʻo | Inā paha e pane ka carousel i nā hanana keyboard. |
hoʻomaha | kaula | boolean | "holo" | Inā hoʻonoho ʻia i Ma nā hāmeʻa hiki ke hoʻopā, ke hoʻonoho ʻia iā |
holo | kaulahao | wahahee | Hoʻokani ʻauʻa i ka carousel ma hope o ka holo lima ʻana o ka mea hoʻohana i ka mea mua. Inā "carousel", ho'okani 'akomi i ka carousel ma ka hoouka. |
kāʻei | boolean | ʻoiaʻiʻo | Inā pono ke kaʻa kaʻa kaʻa kaʻa kaʻa a i ʻole ka paʻakikī. |
Nā ʻano asynchronous a me nā hoʻololi
Asynchronous nā ala API āpau a hoʻomaka i kahi hoʻololi . Hoʻi lākou i ka mea kelepona i ka wā e hoʻomaka ai ka hoʻololi akā ma mua o ka pau ʻana . Eia kekahi, e nānā ʻole ʻia kahi ala e kāhea ai i kahi mea hoʻololi .
Hoʻomaka ka carousel me nā koho koho object
a hoʻomaka i ka holo kaʻa i nā mea.
Kaʻapuni i nā mea carousel mai ka hema a i ka ʻākau.
Hoʻopau i ka carousel mai ka holo paikikala ma nā mea.
Hoʻololi i ka carousel i kahi kiʻi kikoʻī (ma muli o 0, e like me kahi array). E hoʻi i ka mea kelepona ma mua o ka hōʻike ʻia ʻana o ka mea i manaʻo ʻia (ʻo ia hoʻi ma mua o ka hiki ʻana o ka slid.bs.carousel
hanana).
Hoʻoholo i ka mea mua. Hoʻi i ka mea kelepona ma mua o ka hōʻike ʻia ʻana o ka mea mua (ʻo ia hoʻi ma mua o ka hiki ʻana o ka slid.bs.carousel
hanana).
Hoʻoholo i ka mea aʻe. E hoʻi i ka mea kelepona ma mua o ka hōʻike ʻia ʻana o ka mea aʻe (ʻo ia hoʻi ma mua o ka hiki ʻana o ka slid.bs.carousel
hanana).
Hoʻopau i ka carousel o kekahi mea.
Hōʻike ka papa carousel o Bootstrap i ʻelua hanana no ka hoʻopili ʻana i ka hana carousel. Loaʻa i nā hanana ʻelua nā waiwai hou aʻe:
direction
: ʻO ka ʻaoʻao e heʻe ana ka carousel (a i"left"
ʻole"right"
).relatedTarget
: ʻO ka mea DOM e hoʻoneʻe ʻia ana ma ke ʻano he mea hana.from
: Ka papa kuhikuhi o ka mea o keia manawato
: Ka papa kuhikuhi o ka mea aʻe
Hoʻopau ʻia nā hanana carousel a pau i ka carousel ponoʻī (ʻo ia hoʻi ma ka <div class="carousel">
).
ʻAno Hanana | wehewehe |
---|---|
slide.bs.carousel | Hoʻopau koke ʻia kēia hanana i ka wā slide e kāhea ʻia ke ʻano hana. |
slid.bs.carousel | Hoʻopau ʻia kēia hanana ke hoʻopau ka carousel i kāna hoʻololi paheʻe. |