article
, aside
, nav
or section
) to group it with the paginated content.title
attribute to indicate the absolute page number in a sentence.first
, previous
, next
and last
on the corresponding list items.User | Data |
---|---|
Lorem | Lorem ipsum dolor sit amet |
Lorem | Lorem ipsum dolor sit amet |
Lorem | Lorem ipsum dolor sit amet |
An ordered list should be populated correctly when used as pagination. Expected are the following list items (all rendered as a link, except for the active page):
Where p is the number of previous pages, and n the number of next pages.
The aim is to show and move a window of 10 (9 absolute links, 1 active list item) pages. Favour p over n when an odd number of pages needs to be evenly distributed.
Use a nav
element as a container with class pagination
.
Active page is 7, page count is 20.
active
on list item)All the links should have a title
attribute that tells the absolute page number, e.g. "Go to page 1".
Customising the pagination module's style is easy. Here is some example code that would be placed in the main theme file.
/* pagination */
nav.pagination {
font-size: .75rem;
font-weight: bold;
padding: 2rem;
background-color: #f2f2f2;
}
nav.pagination > ol > li:not(:last-child) {
margin-right: .25rem;
}
nav.pagination > ol > li > a,
nav.pagination > ol > li.active {
text-shadow: 0 1px 0 #fff;
padding: .25rem .75rem;
border-radius: .1875rem;
box-shadow: inset 0 1px 0 rgb(255, 255, 255, .8), 0 1px .1875rem rgb(0, 0, 0, .1);
}
nav.pagination > ol > li > a {
color: #717171;
text-decoration: none;
border: 1px solid #c0c0c0;
background: #e9e9e9 linear-gradient(#f8f8f8, #e9e9e9);
}
nav.pagination > ol > li > a:hover {
background: #fefefe linear-gradient(#fefefe, #f0f0f0);
}
nav.pagination > ol > li.active {
color: #f0f0f0;
text-shadow: 0 0 .1875rem rgb(0, 0, 0, .5);
background-color: #616161;
box-shadow: inset 0 0 .5rem rgb(0, 0, 0, .5), 0 1px 0 rgb(255, 255, 255, .8);
}
This code extends the previous example code. It serves as a subtheme example. A subtheme could be used as another style layer on top of the main theme style which is used in special occasions.
/* pagination night */
nav.pagination {
background-color: #414449;
}
nav.pagination > ol > li > a,
nav.pagination > ol > li.active {
color: #feffff;
text-shadow: 0 1px 0 rgb(0, 0, 0, .5);
box-shadow: inset 0 1px 1px rgb(255, 255, 255, .1), 0 1px .1875rem rgb(0, 0, 0, .1);
}
nav.pagination > ol > li > a {
border: solid 1px #32373b;
background: #3e4347 linear-gradient(#565b5f, #3e4347);
}
nav.pagination > ol > li > a:hover {
background: #3d4f5d linear-gradient(#547085, #3d4f5d);
}
nav.pagination > ol > li.active {
background-color: #2f3237;
box-shadow: inset 0 0 .5rem rgb(0, 0, 0, .5), 0 1px 0 rgb(255, 255, 255, .1);
}