Oju-iwe
Iwe ati awọn apẹẹrẹ fun fifi oju-iwe han lati tọka lẹsẹsẹ ti akoonu ti o ni ibatan wa kọja awọn oju-iwe pupọ.
A lo bulọọki nla ti awọn ọna asopọ asopọ fun pagination wa, ṣiṣe awọn ọna asopọ lile lati padanu ati irọrun iwọn-gbogbo lakoko ti o pese awọn agbegbe to buruju. Pagination ti wa ni itumọ pẹlu atokọ HTML awọn eroja ki awọn oluka iboju le kede nọmba awọn ọna asopọ to wa. Lo nkan fifisilẹ <nav>
lati ṣe idanimọ rẹ bi apakan lilọ kiri si iboju awọn oluka iboju ati awọn imọ-ẹrọ iranlọwọ miiran.
Ni afikun, bi awọn oju-iwe ṣe le ni diẹ ẹ sii ju ọkan lọ iru apakan lilọ kiri, o ni imọran lati pese apejuwe kan aria-label
fun <nav>
lati ṣe afihan idi rẹ. Fun apẹẹrẹ, ti a ba lo paati pagination lati lọ kiri laarin akojọpọ awọn abajade wiwa, aami ti o yẹ le jẹ 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>
Ṣe o n wa lati lo aami tabi aami ni aaye ọrọ fun diẹ ninu awọn ọna asopọ pagination? Rii daju lati pese atilẹyin oluka iboju to dara pẹlu aria
awọn abuda ati ohun .sr-only
elo naa.
<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>
Awọn ọna asopọ oju-iwe jẹ asefara fun awọn ipo oriṣiriṣi. Lo .disabled
fun awọn ọna asopọ ti o han lai-tẹ ati .active
lati tọka oju-iwe lọwọlọwọ.
Lakoko ti .disabled
kilasi naa nlo pointer-events: none
lati gbiyanju lati mu iṣẹ ọna asopọ ṣiṣẹ ti <a>
s, ohun-ini CSS naa ko tii diwọn ati pe ko ṣe akọọlẹ fun lilọ kiri keyboard. Bii iru bẹẹ, o yẹ ki o ṣafikun nigbagbogbo tabindex="-1"
lori awọn ọna asopọ alaabo ati lo JavaScript aṣa lati mu iṣẹ wọn ṣiṣẹ ni kikun.
<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>
O le ni yiyan paarọ awọn ìdákọró ti nṣiṣe lọwọ tabi alaabo fun <span>
, tabi fi oran naa silẹ ni ọran ti awọn itọka iṣaaju/tẹle, lati yọ iṣẹ ṣiṣe tẹ kuro ki o ṣe idiwọ idojukọ keyboard lakoko idaduro awọn aṣa ti a pinnu.
<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>
Fancy tobi tabi kere pagination? Fikun -un .pagination-lg
tabi .pagination-sm
fun awọn iwọn afikun.
<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>
Yi titete awọn paati pagination pada pẹlu awọn ohun elo 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>