Source

Pagination

Takaddun bayanai da misalai don nuna shafi don nuna jerin abubuwan da ke da alaƙa suna wanzuwa a cikin shafuka da yawa.

Dubawa

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-labeldon <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>

Aiki tare da gumaka

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 ariahalaye da abin .sr-onlyamfani.

<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">&laquo;</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">&raquo;</span>
        <span class="sr-only">Next</span>
      </a>
    </li>
  </ul>
</nav>

Jihohi naƙasassu da aiki

Ana iya daidaita hanyoyin haɗin yanar gizo don yanayi daban-daban. Yi amfani .disabledda hanyoyin haɗin da suka bayyana ba za a iya dannawa ba kuma .activedon nuna shafin na yanzu.

Yayin da .disabledajin ke amfani pointer-events: noneda 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>

Girman girma

Zaki fi girma ko ƙarami? Ƙara .pagination-lgko .pagination-smdon ƙ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>

Daidaitawa

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>