
Bootstrap Pagination: Pagination is one of the most common feature seen in web based application for managing large number of pages in a systematic way. Bootstrap has default pagination system characterized by specific design and html structure that we will study in this post
Even when you use Search Engines like Google, Bing or Yahoo after limited (10) searches it shows navigation below to showcase the next list of pages.
Pagination in bootstrap 4 is built within nav element proceeded by ul (class=’pagination’) and li with class(.page-item) & anchor tag class (.page-link)accordingly. Each of these elements have respective CSS which imparts its user experience to the viewer respectively.
<ul class="pagination">
<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="#">4</a></li>
<li class="page-item"><a class="page-link" href="#">5</a></li>
</ul> .pagination
{display:-ms-flexbox;display:flex;padding-left:0;
list-style:none;border-radius:.25rem}
.page-link
{position:relative;display:block;padding:.5rem .75rem;margin-left:-1px;line-height:1.25;color:#007bff;background-color:#fff;border:1px solid #dee2e6}
.page-link:hover{z-index:2;color:#0056b3;text-decoration:none;background-color:#e9ecef;border-color:#dee2e6}
.page-link:focus{z-index:2;outline:0;box-shadow:0 0 0 .2rem rgba(0,123,255,.25)}
.page-link:not(:disabled):not(.disabled){cursor:pointer}
.page-item:first-child .page-link{margin-left:0;border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}
.page-item:last-child .page-link{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}
.page-item.active .page-link{z-index:1;color:#fff;background-color:#007bff;border-color:#007bff}
.page-item.disabled .page-link{color:#6c757d;pointer-events:none;cursor:auto;background-color:#fff;border-color:#dee2e6}
.pagination-lg .page-link{padding:.75rem 1.5rem;font-size:1.25rem;line-height:1.5}
.pagination-lg .page-item:first-child .page-link{border-top-left-radius:.3rem;border-bottom-left-radius:.3rem}
.pagination-lg .page-item:last-child .page-link{border-top-right-radius:.3rem;border-bottom-right-radius:.3rem}
.pagination-sm .page-link{padding:.25rem .5rem;font-size:.875rem;line-height:1.5}
.pagination-sm .page-item:first-child .page-link{border-top-left-radius:.2rem;border-bottom-left-radius:.2rem}
.pagination-sm .page-item:last-child .page-link{border-top-right-radius:.2rem;border-bottom-right-radius:.2rem} There are three basic style in pagination with small(sm), default and large(lg) used to depict their sizes accordingly.
This specific class will make the size a bit longer and giving user to highlight its use for that area.(.pagination-lg)
There are two basic states that are defined as being active and disabled respectively. Here we are going to study their behaviour one by one.
Bootstrap pagination Active Example:By adding class active to the li element you can make the pagination highlight current page with active state which characterises with change in their color and background color respectively.
With .active class Background becomes #007bff i.e. dodge blue approx.
Bootstrap Pagination Disabled Example:
With the addition of .disabled class the pagination item becomes dull grey and un-clickable with pointer-events: none.
In this editor find how these values are assigned with change in color and click behaviour
To make pagination take center position as a whole in the design then you need to use two new utility classes of d-flex and mx-auto that imparts Center position to the whole pagination layout respectively.
You can also add new utility class .justify-content-center on the ul structure that imparts centered position to the whole pagination accordingly.
When the number of pages high and you need to restrict the code to your choice of number, then there must be code to get it working accordingly. JavaScript is written to get this effect and thus limit the number of pagination when there are multiple pages accordingly. There are also plugin available which can do this things as per to control the layout of the page.
Check out the simple code for using pagination with table structure with live example and try it editor.
Also checkout how to use pagination with simple PHP code
Also check out how you can use specific dynamic plugin with Jquery that are quite popular with large scale websites.
This component of pager has been dropped from bootstrap entirely but we have added as example to give you further understanding.
When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…
In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…
In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…
In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…
When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…
In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…