Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <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>
              
            
!

CSS

              
                
 .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;
  }
  

  
}
              
            
!

JS

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

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

Console