<div class="container">
<div class="col-md-8 col-md-offset-2">

  <h1>Responsive Pagination</h1>
  <p>Resize the browser. At smaller sizes the pagination expands, making the hit area larger and flowing the content down, instead of a left/right list that will at some point break due to the number of items.</p>
    
  <hr />
    
  <h3>Even number of items</h3>
  <p>This list has an even number of items and divides nicely.</p>

  <ul class="pagination pagination-responsive">
    <li><a href="#">&laquo;</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="#">&raquo;</a></li>
  </ul>
  
  <br />
    
 <h3>Odd number of items</h3>
 <p>To avoid an orphan pagination tile, the first link is wider, though it could be the last or some middle link as well. Javascript decides if there is an odd or even number and puts a contextual class on that pagination unit.</p>
 
  <ul class="pagination pagination-responsive">
    <li><a href="#">&laquo;</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="#">&raquo;</a></li>
  </ul>

   <br />

  <h3>Contextual Labels</h3>
  <p>In it's mobile state, there is additional text.</p>

  <ul class="pagination pagination-responsive">
    <li><a href="#">&laquo; <span class="hidden-sm hidden-md hidden-lg">Previous</span></a></li>
    <li><a href="#"><span class="hidden-sm hidden-md hidden-lg">Page</span> 1</a></li>
    <li><a href="#"><span class="hidden-sm hidden-md hidden-lg">Page</span> 2</a></li>
    <li><a href="#"><span class="hidden-sm hidden-md hidden-lg">Page</span> 3</a></li>
    <li><a href="#"><span class="hidden-sm hidden-md hidden-lg">Page</span> 4</a></li>
    <li><a href="#"><span class="hidden-sm hidden-md hidden-lg">Page</span> 5</a></li>
    <li><a href="#"><span class="hidden-sm hidden-md hidden-lg">Page</span> 6</a></li>
    <li><a href="#"><span class="hidden-sm hidden-md hidden-lg">Next</span> &raquo;</a></li>
  </ul>

  
  
</div>
</div>

 .container{
   text-align:center;
 }
  
p{
  color:#999;
}

*, *:before, *:after {
  -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
 }




/* Small devices (tablets, 768px and up) */
@media (max-width: 767px) {
  
   .pagination{
     width:100%;
     border-radius:0px;
   }
  
  .pagination > li > a, .pagination > li > span{
    width:50%;
    display:block;
    text-align:center;
    border-radius:0px;
    margin-left:0px;
    border-width: 1px 0 0 1px;

  }
  
  .pagination.even > li:nth-child(even) > a, .pagination > li:nth-child(even) > span{
    border-right:solid 1px #DDDDDD;
  }

  .pagination.even > li:first-child > a, .pagination > li:first-child > span{
    border-radius:4px 0px 0px 0px;
  }
  
  .pagination.even > li:nth-child(2) > a, .pagination > li:first-child > span{
    border-radius:0px 4px 0px 0px;
  }
  
  .pagination.even > li:last-child > a, .pagination > li:last-child > span{
    border-bottom:solid 1px #DDDDDD;
    border-radius:0px 0px 4px 0px;
  }
  
  .pagination.even > li:nth-last-child(2) > a, .pagination > li:nth-last-child(2) > span{
    border-bottom:solid 1px #DDDDDD;
    border-radius:0px 0px 0px 4px;
  }
  

  
  .pagination.odd > li:nth-child(odd) > a, .pagination > li:nth-child(odd) > span{
    border-right:solid 1px #DDDDDD;
  }

  .pagination.odd > li:first-child > a, .pagination > li:first-child > span{
    border-radius:4px 4px 0px 0px;
    border-bottom:0px;
    width:100%;
  }

  .pagination.odd > li:last-child > a, .pagination > li:last-child > span{
    border-bottom:solid 1px #DDDDDD;
    border-radius:0px 0px 4px 0px;
  }
  
  .pagination.odd > li:nth-last-child(2) > a, .pagination > li:nth-last-child(2) > span{
    border-bottom:solid 1px #DDDDDD;
    border-radius:0px 0px 0px 4px;
  }
  

  
}
$('.pagination-responsive').each(function() {

		var listItems = $(this).children();
  
		if (listItems.length%2 == 0){
			$(this).addClass('even');
		} else{
			$(this).addClass('odd');
		}
  
});
Run Pen

External CSS

  1. //netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css

External JavaScript

  1. //cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js
  2. //netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js