Panagpagina
Ti dokumentasion ken dagiti pagarigan para iti panangiparang ti panid tapno mangipakita ti serye ti mainaig a linaon ket adda iti ballasiw dagiti adu a panid.
Panangkita iti pakabuklan
Usarenmi ti dakkel a bloke dagiti naikonektar a silpo para iti paginationmi, a mamagbalin kadagiti silpo a narigat a malipatan ken nalaka a maipadakkel—amin bayat a mangipaay kadagiti dadakkel a nadungpar a lugar. Ti pagination ket naibangon babaen dagiti elemento ti listaan ti HTML tapno dagiti agbasbasa ti iskrin ket mabalinda nga ipakaammo ti bilang dagiti magun-od a silpo. Usaren ti <nav>
elemento ti panagbalkot tapno mailasin daytoy a kas maysa a benneg ti nabigasion tapno i-screen dagiti agbasbasa ken dadduma pay a makatulong a teknolohia.
Iti pay maipatinayon, gapu ta dagiti panid ket mabalin nga addaan iti ad-adu ngem maysa a kasta a benneg ti panaglayag, maibalakad ti mangipaay ti mangiladawan aria-label
para iti <nav>
tapno maiparangarang ti panggepna. Kas pagarigan, no ti paset ti panagpagina ket maus-usar a mangiturong iti nagbaetan ti maysa a grupo dagiti resulta ti panagbiruk, ti maitutop nga etiketa ket mabalin a 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>
Panagtrabaho kadagiti icon
Agsapsapulka kadi nga agusar iti ikono wenno simbolo a kasukat ti teksto para iti sumagmamano a silpo ti pagination? Siguraduen nga ipaay ti umno a suporta ti screen reader nga addaan kadagiti aria
attribute.
<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>
</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>
</a>
</li>
</ul>
</nav>
Baldado ken aktibo nga estado
Dagiti silpo ti pagination ket mabalin a maibagay para kadagiti nadumaduma a kasasaad. Usaren .disabled
para kadagiti silpo a kasla saan a mai-click ken .active
tapno mangipakita ti agdama a panid.
Bayat nga agus- .disabled
usar ti klase pointer-events: none
a mangpadas a mangbaldado ti panagandar ti silpo ti <a>
s, dayta a tagikua ti CSS ket saan pay a naistandard ken saan a mangikuenta ti panaglayag ti teklado. Kas kasta, rumbeng a kanayon a mangnayonka tabindex="-1"
kadagiti nabaldado a silpo ken agusarka iti kostumbre a JavaScript tapno naan-anay a mapasardeng ti panagandar dagitoy.
<nav aria-label="...">
<ul class="pagination">
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a>
</li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item active" aria-current="page">
<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>
Mabalinmo nga opsional nga isukat dagiti aktibo wenno baldado nga angkla para iti <span>
, wenno liklikan ti angkla iti kaso dagiti immun-una/sumaruno a pana, tapno maikkat ti panagusar ti panagpidut ken malapdan ti panagpokus ti teklado bayat ti panangtaginayon kadagiti nairanta nga estilo.
<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" aria-current="page">
<span class="page-link">2</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>
Panag-sizing
Magarbo a dakdakkel wenno basbassit a pagination? Inayon .pagination-lg
wenno .pagination-sm
para kadagiti kanayonan a kadakkel.
<nav aria-label="...">
<ul class="pagination pagination-lg">
<li class="page-item active" aria-current="page">
<span class="page-link">1</span>
</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 active" aria-current="page">
<span class="page-link">1</span>
</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>
Panagtunos
Baliwan ti panagtunos dagiti paset ti pagination kadagiti flexbox a utilidad .
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1" aria-disabled="true">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" aria-disabled="true">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>
Sass nga
Dagiti Variable
$pagination-padding-y: .375rem;
$pagination-padding-x: .75rem;
$pagination-padding-y-sm: .25rem;
$pagination-padding-x-sm: .5rem;
$pagination-padding-y-lg: .75rem;
$pagination-padding-x-lg: 1.5rem;
$pagination-color: $link-color;
$pagination-bg: $white;
$pagination-border-width: $border-width;
$pagination-border-radius: $border-radius;
$pagination-margin-start: -$pagination-border-width;
$pagination-border-color: $gray-300;
$pagination-focus-color: $link-hover-color;
$pagination-focus-bg: $gray-200;
$pagination-focus-box-shadow: $input-btn-focus-box-shadow;
$pagination-focus-outline: 0;
$pagination-hover-color: $link-hover-color;
$pagination-hover-bg: $gray-200;
$pagination-hover-border-color: $gray-300;
$pagination-active-color: $component-active-color;
$pagination-active-bg: $component-active-bg;
$pagination-active-border-color: $pagination-active-bg;
$pagination-disabled-color: $gray-600;
$pagination-disabled-bg: $white;
$pagination-disabled-border-color: $gray-300;
$pagination-transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
$pagination-border-radius-sm: $border-radius-sm;
$pagination-border-radius-lg: $border-radius-lg;
Dagiti Mixin
@mixin pagination-size($padding-y, $padding-x, $font-size, $border-radius) {
.page-link {
padding: $padding-y $padding-x;
@include font-size($font-size);
}
.page-item {
@if $pagination-margin-start == (-$pagination-border-width) {
&:first-child {
.page-link {
@include border-start-radius($border-radius);
}
}
&:last-child {
.page-link {
@include border-end-radius($border-radius);
}
}
} @else {
//Add border-radius to all pageLinks in case they have left margin
.page-link {
@include border-radius($border-radius);
}
}
}
}