Pagination
Dark pagination for you today. Play with it a little and look into css/js.
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Cart - Design it & Code it</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="reset.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="pagination">
<ul>
<li class="prev 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 class="next"><a href="#">></a></li>
</ul>
</div>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/script.js" type="text/javascript"></script>
</body>
</html>CSS
html { background: #f5f5f5 url(img/bg.png); }
body {
margin: 180px auto 0 auto;
max-width: 500px;
width: 100%;
}
a {
-webkit-transition: all .2s linear;
-moz-transition: all .2s linear;
transition: all .2s linear;
}
@font-face {
font-family: 'Edmondsans';
src: url('fonts/edmondsans-bold-webfont.eot');
src: url('fonts/edmondsans-bold-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/edmondsans-bold-webfont.woff') format('woff'),
url('fonts/edmondsans-bold-webfont.ttf') format('truetype'),
url('fonts/edmondsans-bold-webfont.svg#EdmondsansBoldRegular') format('svg');
font-weight: bold;
font-style: normal;
}
/*
* Custom style
*/
.pagination li {
border-top-color: #282828;
border-bottom-color: #282828;
}
.pagination li:before,
.pagination .active:after,
.pagination .active:before,
.pagination .active ~ li:before {
border-left-color: #282828;
border-right-color: #282828;
}
.pagination a {
color: #888;
font-family: "Edmondsans";
font-size: 15px;
font-weight: bold;
text-decoration: none;
}
.pagination .active a { color: #ccc; }
.pagination .disabled a,
.pagination .disabled:hover a { color: #333; cursor: default; }
.pagination li:hover a { color: #c9282d; }
/*
* Basic style
*/
.pagination { text-align: center; }
.pagination ul {
display: inline-block;
list-style-type: none;
margin: 0;
padding: 0;
text-align: center;
}
.pagination li {
border-right:10px solid transparent;
border-bottom-width: 17px;
border-top-width: 17px;
border-style: solid;
border-left: 0;
height: 0;
float: left;
margin-right: 3px;
position: relative;
}
.pagination li:before {
border-bottom-color: transparent;
border-left-color: transparent;
border-top-color: transparent;
border-width: 17px 10px 17px 0;
border-style: solid;
position: absolute;
content: '';
left: -10px;
height: 0px;
top: -17px;
width: 0px;
}
.pagination .active ~ li:before {
border-bottom-color: transparent;
border-top-color: transparent;
border-width: 17px 0 17px 10px;
right: -10px;
left: auto;
}
.pagination .active ~ li {
border-left:10px solid transparent;
border-right: 0;
}
.pagination .active {
border-right: 0;
border-left: 0;
}
.pagination .active:after,
.pagination .active:before {
border-bottom-color: transparent;
border-top-color: transparent;
border-width: 17px 10px 17px 0;
border-style: solid;
position: absolute;
content: '';
height: 0px;
width: 0px;
top: -17px;
left: -10px;
}
.pagination .active:after {
border-bottom-color: transparent;
border-right-color: transparent;
border-top-color: transparent;
border-width: 17px 0 17px 10px;
right: -10px;
left: auto;
}
.pagination a {
line-height: 36px;
margin-top: -17px;
display: block;
height: 34px;
width: 30px;
}
.pagination .prev {
-webkit-border-radius: 20px 0 0 20px;
-moz-border-radius: 20px 0 0 20px;
border-radius: 20px 0 0 20px;
}
.pagination .next {
-webkit-border-radius: 0 20px 20px 0;
-moz-border-radius: 0 20px 20px 0;
border-radius: 0 20px 20px 0;
border-right: 0;
}
.pagination .prev a,
.pagination .next a {
text-indent: -4px;
line-height: 38px;
font-size: 30px;
}
.pagination .prev a { text-indent: 4px; }
.pagination .prev:before,
.pagination .next:before { content: none; }JavaScript
/* Pagination by @Idered | http://designitcodeit.com/i/14 */
;(function ( $, window, document, undefined ) {
$('.pagination li').on('click', function(event) {
event.preventDefault();
var $this = $(this),
$pagination = $this.parent(),
$pages = $pagination.children(),
$active = $pagination.find('.active');
if($this.hasClass('prev')) {
if ($pages.index($active) > 1) {
$active.removeClass('active').prev().addClass('active');
}
} else if($this.hasClass('next')) {
if ($pages.index($active) < $pages.length - 2) {
$active.removeClass('active').next().addClass('active');
}
} else {
$this.addClass('active').siblings().removeClass('active');
}
$active = $pagination.find('.active');
$('.prev')[$pages.index($active) == 1 ? 'addClass' : 'removeClass']('disabled');
$('.next')[$pages.index($active) == $pages.length - 2 ? 'addClass' : 'removeClass']('disabled');
});
$('.pagination li:eq(1)').trigger('click');
})( jQuery, window, document );