All for Joomla All for Webmasters

Bootstrap Pagination

Pagination is used to sort the web pages of your website in an organized manner. It becomes very necessary if your website has a lot of web pages.

Following is a list of classes that Bootstrap provides to handle pagination.

Table:

Class Description
.pagination Add this class to get the pagination on your page.
.disabled,

.active
you can customize links by using .disabled for unclickable links and .active to indicate the current page.
.pagination-lg,

.pagination-sm
use these classes to get different size items.

Bootstrap Pagination Example

Add the .pagination class to an <ul> element to create a basic pagination.

See this example:

  1. <!DOCTYPE html>
  2. <html lang=“en”>
  3. <head>
  4.   <title>Bootstrap Example</title>
  5.   <meta charset=“utf-8”>
  6.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  7.   <link rel=“stylesheet” href=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>
  8. </head>
  9. <body>
  10. <div class=“container”>
  11.   <h2>A basic pagination example:</h2>
  12.   <p>The .pagination class provides pagination links:</p>
  13.   <ul class=“pagination”>
  14.     <li><a href=“#”>1</a></li>
  15.     <li><a href=“#”>2</a></li>
  16.     <li><a href=“#”>3</a></li>
  17.     <li><a href=“#”>4</a></li>
  18.     <li><a href=“#”>5</a></li>
  19.   </ul>
  20. </div>
  21. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  22. <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  23. </body>
  24. </html>

Bootstrap Active State

The active state specifies the current page on which user is active.

The class .active is used to specify active state.

See this example:

  1. <!DOCTYPE html>
  2. <html lang=“en”>
  3. <head>
  4.   <title>Bootstrap Example</title>
  5.   <meta charset=“utf-8”>
  6.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  7.   <link rel=“stylesheet” href=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>
  8. </head>
  9. <body>
  10. <div class=“container”>
  11.   <h2>Active State Pagination: Example</h2>
  12. <p>Specify the current active state of the user.</p>
  13.   <ul class=“pagination”>
  14.     <li><a href=“#”>1</a></li>
  15.     <li class=“active”><a href=“#”>2</a></li>
  16.     <li><a href=“#”>3</a></li>
  17.     <li><a href=“#”>4</a></li>
  18.     <li><a href=“#”>5</a></li>
  19.   </ul>
  20. </div>
  21.  <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  22.  <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  23. </body>
  24. </html>

Bootstrap Disabled State

The disabled state specifies that you cannot click on the link.

Add class .disabled to disable the links you don’t need more.

See this example:

  1. <!DOCTYPE html>
  2. <html lang=“en”>
  3. <head>
  4.   <title>Bootstrap Example</title>
  5.   <meta charset=“utf-8”>
  6.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  7.   <link rel=“stylesheet” href=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>
  8. </head>
  9. <body>
  10. <div class=“container”>
  11.   <h2>Disabled State Pagination Example:</h2>
  12.   <p>Here, 4 and 5 links are disabled.</p>
  13.   <ul class=“pagination”>
  14.     <li><a href=“#”>1</a></li>
  15.     <li><a href=“#”>2</a></li>
  16.     <li><a href=“#”>3</a></li>
  17.     <li class=“disabled”><a href=“#”>4</a></li>
  18.     <li><a href=“#”>5</a></li>
  19.   </ul>
  20. </div>
  21.  <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  22.  <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  23. </body>
  24. </html>

Bootstrap Pagination Sizing

You can also size pagination blocks larger or smaller accordingly.

Add class .pagination-lg for larger blocks or .pagination-sm for smaller blocks.

See this example:

  1. <!DOCTYPE html>
  2. <html lang=“en”>
  3. <head>
  4.   <title>Bootstrap Example</title>
  5.   <meta charset=“utf-8”>
  6.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  7.   <link rel=“stylesheet” href=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>
  8. </head>
  9. <body>
  10. <div class=“container”>
  11.   <h2>Pagination – Sizing</h2>
  12.   <p>Add class .pagination-lg for larger blocks or .pagination-sm for smaller blocks:</p>
  13.   <ul class=“pagination pagination-lg”>
  14.     <li><a href=“#”>1</a></li>
  15.     <li><a href=“#”>2</a></li>
  16.     <li><a href=“#”>3</a></li>
  17.     <li><a href=“#”>4</a></li>
  18.     <li><a href=“#”>5</a></li>
  19.   </ul>
  20.   <ul class=“pagination pagination-sm”>
  21.     <li><a href=“#”>1</a></li>
  22.     <li><a href=“#”>2</a></li>
  23.     <li><a href=“#”>3</a></li>
  24.     <li><a href=“#”>4</a></li>
  25.     <li><a href=“#”>5</a></li>
  26.   </ul>
  27. </div>
  28. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  29. <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  30. </body>
  31. </html>

Bootstrap Breadcrumbs

It is another form of pagination. It indicates the current page’s location within a navigational hierarchy.

The .breadcrumb class is used to create breadcrumbs.

See this example:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  5.   <link rel=“stylesheet” href=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>
  6. </head>
  7. <body>
  8. <div class=“container”>
  9.   <h2>Breadcrumbs Example:</h2>
  10.   <p>The .breadcrumb class indicates the current page’s location within a navigational hierarchy:</p>
  11.   <ul class=“breadcrumb”>
  12.     <li><a href=“#”>Java</a></li>
  13.     <li><a href=“#”>SQL</a></li>
  14.     <li><a href=“#”>Php</a></li>
  15.     <li class=“active”>.Net</li>
  16.   </ul>
  17. </div>
  18. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  19. <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  20. </body>
  21. </html>

 

PinIt
submit to reddit

Leave a Reply

Top