Ka helu helu
ʻO nā palapala a me nā laʻana no ka hōʻike ʻana i ka helu helu helu e hōʻike i ke ʻano o nā ʻike pili i loaʻa ma nā ʻaoʻao he nui.
Nānā nui
Hoʻohana mākou i kahi poloka nui o nā loulou pili no kā mākou pagination, e hana ana i nā loulou paʻakikī e nalo a maʻalahi hoʻi i hoʻonui ʻia - ʻoiai e hāʻawi ana i nā wahi pā nui. Kūkulu ʻia ka ʻaoʻao me nā mea HTML papa inoa i hiki i ka poʻe heluhelu heluhelu ke hoʻolaha i ka helu o nā loulou i loaʻa. E hoʻohana i kahi mea ʻōwili <nav>
e hoʻomaopopo iā ia ma ke ʻano he ʻāpana hoʻokele e nānā i ka poʻe heluhelu a me nā ʻenehana kōkua ʻē aʻe.
Eia hou, no ka mea, ʻoi aku ka nui o nā ʻaoʻao ma mua o hoʻokahi ʻāpana hoʻokele, pono e hāʻawi i kahi wehewehe aria-label
no ka <nav>
hōʻike ʻana i kāna kumu. No ka laʻana, inā hoʻohana ʻia ka ʻāpana pagination no ka hoʻokele ʻana ma waena o kahi pūʻulu o nā hopena hulina, hiki i kahi lepili kūpono ke 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>
Ke hana nei me nā kiʻi
Ke ʻimi nei e hoʻohana i kahi ikona a i ʻole hōʻailona ma kahi o ka kikokikona no kekahi mau loulou pagination? E ʻoluʻolu e hāʻawi i ke kākoʻo heluhelu pale kūpono me aria
nā ʻano.
<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>
Nā mokuʻāina kīnā ʻole a ʻeleu
Hoʻopilikino ʻia nā loulou ʻaoʻao no nā kūlana like ʻole. E hoʻohana .disabled
no nā loulou i ʻike ʻia ʻaʻole hiki ke kaomi a .active
hōʻike i ka ʻaoʻao o kēia manawa.
ʻOiai .disabled
e hoʻohana ana ka papa pointer-events: none
e hoʻāʻo e hoʻopau i ka hana loulou o <a>
s, ʻaʻole i hoʻopaʻa ʻia kēlā waiwai CSS a ʻaʻole helu no ka hoʻokele keyboard. No laila, pono ʻoe e hoʻohui mau tabindex="-1"
i nā loulou kīnā ʻole a hoʻohana i ka JavaScript maʻamau e hoʻopau piha i kā lākou hana.
<nav aria-label="...">
<ul class="pagination">
<li class="page-item disabled">
<a class="page-link">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>
Hiki iā ʻoe ke hoʻololi i nā heleuma ikaika a i ʻole nā heleuma no <span>
, a i ʻole e haʻalele i ka heleuma ma ke ʻano o nā pua mua / aʻe, e wehe i ka hana kaomi a pale i ka nānā ʻana i ka keyboard me ka mālama ʻana i nā ʻano i manaʻo ʻia.
<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>
Ka nui ana
Makemake ʻoe i ka helu helu nui a liʻiliʻi paha? Hoʻohui a i .pagination-lg
ʻole .pagination-sm
no nā nui ʻē aʻe.
<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>
Hoʻopololei
E hoʻololi i ka hoʻonohonoho ʻana o nā ʻāpana pagination me nā pono hana flexbox .
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li class="page-item disabled">
<a class="page-link">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">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
Nā mea hoʻololi
$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;
Mea huikau
@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);
}
}
}
}