Bootstrap pagination is the simplest way of creating pagination for your website pages. If you have large size content and you want to arrange them in separate pages, you can use pagination.
Almost every website requires pagination to organize its content in the managed way. If you are using the Search Engines like Google, You can see pagination for the search website links. To see more content on a page, you have to click the next pagination link.
If you are running a blog, you can see a list of blog posts with pagination.
Create Bootstrap Pagination
Bootstrap pagination requires an only class .pagination
to add to the <ul> tag.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<ul class="pagination"> <li><a href="#">«</a></li> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> <li><a href="#">6</a></li> <li><a href="#">7</a></li> <li><a href="#">8</a></li> <li><a href="#">9</a></li> <li><a href="#">»</a></li> </ul> |
Output
The above example contains several links to pagination if you want to see more content on a website you can click each links one-by-one.
Change the Navigational States to Active/Disabled
Showing pagination links on your website need different navigational states. Suppose, if you click a pagination link and your current location is page no 9. You will have to make 9 as the current active pagination link by using the class .active
.
Sometimes, you also need your users to not to visit on some pages. In that situation, you can make it disabled by using the class .disabled
.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<ul class="pagination"> <li class="disabled"><a href="#">«</a></li> <li class="active"><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> <li><a href="#">6</a></li> <li><a href="#">7</a></li> <li><a href="#">8</a></li> <li><a href="#">9</a></li> <li><a href="#">»</a></li> </ul> |
Output
In the above example, the active link has primary as a background color. The first link is the disabled link which does not allow users to click on it. You can hover over the link and check if it allows you to click on the link or not.
Change the Size of Pagination
Bootstrap pagination comes with three class .pagination-lg
, .pagination-md
and .pagination-sm
. You can use these classes to change the size of pagination as per your need.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
<ul class="pagination pagination-lg"> <li class="disabled"><a href="#">«</a></li> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> <li><a href="#">6</a></li> <li><a href="#">7</a></li> <li><a href="#">8</a></li> <li><a href="#">9</a></li> <li><a href="#">»</a></li> </ul> <ul class="pagination pagination-md"> <li class="disabled"><a href="#">«</a></li> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> <li><a href="#">6</a></li> <li><a href="#">7</a></li> <li><a href="#">8</a></li> <li><a href="#">9</a></li> <li><a href="#">»</a></li> </ul> <ul class="pagination pagination-sm"> <li class="disabled"><a href="#">«</a></li> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> <li><a href="#">6</a></li> <li><a href="#">7</a></li> <li><a href="#">8</a></li> <li><a href="#">9</a></li> <li><a href="#">»</a></li> </ul> |
Output
Create Bootstrap Pager
If you have ever visited any blog posts, you may see a next and previous links there. These links are called pager links which you can click to visit the next and previous pages of your website.
To create a pager, you have to use the class .pager
as the class of the <ul> tag with two list items previous and next links.
1 2 3 4 |
<ul class="pager"> <li><a href="#">Previous</a></li> <li><a href="#">Next</a></li> </ul> |
Output
Align Bootstrap Pager
You can also align the above-created pager by using the class .previous
as the of the previous link and class .next
as the class of the next link.
The class .previous
aligns to the left side and class .next
aligns to the right side.
1 2 3 4 |
<ul class="pager"> <li class="previous"><a href="#">← Previous</a></li> <li class="next"><a href="#">Next →</a></li> </ul> |
Output
Disable state of Pager
You can disable the pager links by using the class .disabled
as the class of the disabled pager link.
1 2 3 4 |
<ul class="pager"> <li class="previous disabled"><a href="#">← Previous</a></li> <li class="next"><a href="#">Next →</a></li> </ul> |
Output
Advertisements
Advertisements