Pagination
Akwụkwọ na ihe atụ maka igosi pagination iji gosi usoro ọdịnaya metụtara dị n'ofe ibe.
Nchịkọta
Anyị na-eji nnukwu ngọngọ nke njikọ njikọ maka pagination anyị, na-eme ka njikọ siri ike na-atụfu na mfe scalable-niile mgbe na-enye nnukwu hit ebe. Ejiri ihe ndetu HTML wuo pagination ka ndị na-agụ enyo nwee ike ịkpọsa ọnụọgụ njikọ dị. Jiri ihe mkpuchi <nav>
iji mata ya dị ka ngalaba nsoroụzọ iji lelee ndị na-agụ akwụkwọ na teknụzụ enyemaka ndị ọzọ.
Na mgbakwunye, dị ka ibe nwere ike inwe ihe karịrị otu ngalaba nsogharị dị otú ahụ, ọ dị mma ịnye nkọwa aria-label
maka <nav>
iji gosipụta ebumnuche ya. Dịka ọmụmaatụ, ọ bụrụ na ejiri akụkụ pagination mee njem n'etiti otu nsonaazụ ọchụchọ, akara kwesịrị ekwesị nwere ike ịbụ 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>
Arụ ọrụ na akara ngosi
Ị na-achọ iji akara ngosi ma ọ bụ akara n'ọnọdụ ederede maka ụfọdụ njikọ pagination? Jide n'aka na ịnye nkwado ndị na-agụ ihuenyo kwesịrị ekwesị na aria
njirimara.
<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>
Steeti nwere nkwarụ na arụ ọrụ
Enwere ike ịhazi njikọ pagination maka ọnọdụ dị iche iche. Jiri .disabled
maka njikọ ndị na-egosi enweghị ịpị na .active
igosi ibe dị ugbu a.
Ọ bụ ezie na .disabled
klaasị na-eji pointer-events: none
agbalị gbanyụọ ọrụ njikọ nke <a>
s, ihe onwunwe CSS ahụ ahazibeghị nke ọma yana ọ nweghị akaụntụ maka igodo igodo. Dị ka nke a, ị ga-agbakwunye tabindex="-1"
na njikọ ndị nwere nkwarụ mgbe niile wee jiri Javascript omenala iji gbanyụọ ọrụ ha kpamkpam.
<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>
Ị nwere ike gbanwee arịlịka na-arụ ọrụ ma ọ bụ nwere nkwarụ maka <span>
, ma ọ bụ hapụ arịlịka n'ihe gbasara akụ ndị gara aga/ na-esote, iji wepụ ọrụ pịa ma gbochie nleba anya ahụigodo ka ị na-ejigide ụdị echere.
<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>
Nha nha
Ọ na-amasị gị ibu ma ọ bụ obere pagination? Tinye .pagination-lg
ma ọ bụ .pagination-sm
maka nha ndị ọzọ.
<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>
Nhazi
Gbanwee nhazi nke akụkụ pagination na ngwa 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" 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
Mgbanwe
$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;
Ngwakọta
@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);
}
}
}
}