Pagination
Takaddun bayanai da misalai don nuna shafi don nuna jerin abubuwan da ke da alaƙa suna wanzuwa a cikin shafuka da yawa.
Muna amfani da babban toshe hanyoyin haɗin yanar gizon mu, yin hanyoyin haɗin kai da wuya a rasa kuma a sauƙaƙe - duk yayin samar da manyan wuraren da aka buge. An gina pagination tare da jerin abubuwan HTML don haka masu karatun allo zasu iya sanar da adadin hanyoyin haɗin yanar gizo. Yi amfani da abin rufewa <nav>
don gano shi azaman sashin kewayawa don tantance masu karatu da sauran fasahar taimako.
Bugu da kari, kamar yadda yuwuwar shafuka suna da irin wannan sashin kewayawa fiye da ɗaya, yana da kyau a samar da siffata aria-label
don <nav>
nuna manufarsa. Misali, idan an yi amfani da ɓangaren rubutun don kewaya tsakanin saitin sakamakon bincike, alamar da ta dace zata iya zama aria-label="Search results pages"
.
<nav aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item"><a class="page-link" href="#">Next</a></li>
</ul>
</nav>
Ana neman amfani da gunki ko alama a wurin rubutu don wasu hanyoyin haɗin yanar gizo? Tabbatar da samar da ingantaccen tallafin mai karanta allo tare da aria
halaye da abin .sr-only
amfani.
<nav aria-label="Page navigation example">
<ul class="pagination">
<li class="page-item">
<a class="page-link" href="#" aria-label="Previous">
<span aria-hidden="true">«</span>
<span class="sr-only">Previous</span>
</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">»</span>
<span class="sr-only">Next</span>
</a>
</li>
</ul>
</nav>
Ana iya daidaita hanyoyin haɗin yanar gizo don yanayi daban-daban. Yi amfani .disabled
da hanyoyin haɗin da suka bayyana ba za a iya dannawa ba kuma .active
don nuna shafin na yanzu.
Yayin da .disabled
ajin ke amfani pointer-events: none
da shi don ƙoƙarin kashe aikin haɗin yanar gizo na <a>
s, wannan kadarorin CSS ba a daidaita ba tukuna kuma baya lissafin kewayawa madannai. Don haka, koyaushe yakamata ku ƙara tabindex="-1"
akan hanyoyin haɗin yanar gizo na nakasa kuma kuyi amfani da JavaScript na al'ada don musaki cikakken aikin su.
<nav aria-label="...">
<ul class="pagination">
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1">Previous</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item active">
<a class="page-link" href="#">2 <span class="sr-only">(current)</span></a>
</li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#">Next</a>
</li>
</ul>
</nav>
Kuna iya zaɓin musanya anka masu aiki ko nakasassu don <span>
, ko barin anka a cikin yanayin kiban da suka gabata/na gaba, don cire ayyukan dannawa da hana mayar da hankali kan madannai yayin riƙe da salon da aka yi niyya.
<nav aria-label="...">
<ul class="pagination">
<li class="page-item disabled">
<span class="page-link">Previous</span>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item active">
<span class="page-link">
2
<span class="sr-only">(current)</span>
</span>
</li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#">Next</a>
</li>
</ul>
</nav>
Zaki fi girma ko ƙarami? Ƙara .pagination-lg
ko .pagination-sm
don ƙarin girma.
<nav aria-label="...">
<ul class="pagination pagination-lg">
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1">1</a>
</li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
</ul>
</nav>
<nav aria-label="...">
<ul class="pagination pagination-sm">
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1">1</a>
</li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
</ul>
</nav>
Canja jeri na abubuwan haɗin shafi tare da kayan aikin flexbox .
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1">Previous</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#">Next</a>
</li>
</ul>
</nav>
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-end">
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1">Previous</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">3</a></li>
<li class="page-item">
<a class="page-link" href="#">Next</a>
</li>
</ul>
</nav>