1.

 Pagination in Bootstrap?

Answer»

With Bootstrap, you can easily add Pagination on any web page. This is useful if you have a lot of linked posts and pages.

Some classes in Bootstrap are useful in creating a basic pagination. Let us see them below:

To create a basic pagination, you need to use the <ul> tag. Include the .pagination class to this <ul> and then add the .page-item to each <li> tag.

The following pagination has active post as 2nd. We have active USING the “.active” class to display the current post/ page:

<!DOCTYPE HTML> <html lang="EN"> <head>   <title>Bootstrap Navbar</title>   <meta charset="utf-8">   <meta name="viewport" content="width=device-width, initial-scale=1">   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> </head> <body>  <div class="container">   <h2>Post 2</h2>   <p>The following is a demo line.</p>       <p>The following is a demo line.</p>                     <p>The following is a demo line.</p>                     <p>The following is a demo line.</p>                     <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 active"><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>     <li class="page-item"><a class="page-link" href="#">6</a></li>     <li class="page-item"><a class="page-link" href="#">Next</a></li>   </ul>  </div> </body> </html>

The output below displays demo content and pagination with next/ previous links as well:



Discussion

No Comment Found