mirror of
https://github.com/twbs/bootstrap.git
synced 2022-11-09 12:25:43 -05:00
Merge pull request #18110 from twbs/pagination-classes
Refactor pagination classes to avoid tag selectors & child selectors
This commit is contained in:
commit
a9f53f0fc0
3 changed files with 81 additions and 92 deletions
|
@ -18,19 +18,19 @@ Simple pagination inspired by Rdio, great for apps and search results. The large
|
||||||
{% example html %}
|
{% example html %}
|
||||||
<nav>
|
<nav>
|
||||||
<ul class="pagination">
|
<ul class="pagination">
|
||||||
<li>
|
<li class="page-item">
|
||||||
<a href="#" aria-label="Previous">
|
<a class="page-link" href="#" aria-label="Previous">
|
||||||
<span aria-hidden="true">«</span>
|
<span aria-hidden="true">«</span>
|
||||||
<span class="sr-only">Previous</span>
|
<span class="sr-only">Previous</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#">1</a></li>
|
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
||||||
<li><a href="#">2</a></li>
|
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||||
<li><a href="#">3</a></li>
|
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||||
<li><a href="#">4</a></li>
|
<li class="page-item"><a class="page-link" href="#">4</a></li>
|
||||||
<li><a href="#">5</a></li>
|
<li class="page-item"><a class="page-link" href="#">5</a></li>
|
||||||
<li>
|
<li class="page-item">
|
||||||
<a href="#" aria-label="Next">
|
<a class="page-link" href="#" aria-label="Next">
|
||||||
<span aria-hidden="true">»</span>
|
<span aria-hidden="true">»</span>
|
||||||
<span class="sr-only">Next</span>
|
<span class="sr-only">Next</span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -46,21 +46,21 @@ Links are customizable for different circumstances. Use `.disabled` for unclicka
|
||||||
{% example html %}
|
{% example html %}
|
||||||
<nav>
|
<nav>
|
||||||
<ul class="pagination">
|
<ul class="pagination">
|
||||||
<li class="disabled">
|
<li class="page-item disabled">
|
||||||
<a href="#" aria-label="Previous">
|
<a class="page-link" href="#" aria-label="Previous">
|
||||||
<span aria-hidden="true">«</span>
|
<span aria-hidden="true">«</span>
|
||||||
<span class="sr-only">Previous</span>
|
<span class="sr-only">Previous</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="active">
|
<li class="page-item active">
|
||||||
<a href="#">1 <span class="sr-only">(current)</span></a>
|
<a class="page-link" href="#">1 <span class="sr-only">(current)</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#">2</a></li>
|
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||||
<li><a href="#">3</a></li>
|
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||||
<li><a href="#">4</a></li>
|
<li class="page-item"><a class="page-link" href="#">4</a></li>
|
||||||
<li><a href="#">5</a></li>
|
<li class="page-item"><a class="page-link" href="#">5</a></li>
|
||||||
<li>
|
<li class="page-item">
|
||||||
<a href="#" aria-label="Next">
|
<a class="page-link" href="#" aria-label="Next">
|
||||||
<span aria-hidden="true">»</span>
|
<span aria-hidden="true">»</span>
|
||||||
<span class="sr-only">Next</span>
|
<span class="sr-only">Next</span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -74,13 +74,13 @@ You can optionally swap out active or disabled anchors for `<span>`, or omit the
|
||||||
{% example html %}
|
{% example html %}
|
||||||
<nav>
|
<nav>
|
||||||
<ul class="pagination">
|
<ul class="pagination">
|
||||||
<li class="disabled">
|
<li class="page-item disabled">
|
||||||
<span aria-label="Previous">
|
<span class="page-link" aria-label="Previous">
|
||||||
<span aria-hidden="true">«</span>
|
<span aria-hidden="true">«</span>
|
||||||
<span class="sr-only">Previous</span>
|
<span class="sr-only">Previous</span>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="active"><span>1 <span class="sr-only">(current)</span></span></li>
|
<li class="page-item active"><span class="page-link">1 <span class="sr-only">(current)</span></span></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
{% endexample %}
|
{% endexample %}
|
||||||
|
@ -93,17 +93,17 @@ Fancy larger or smaller pagination? Add `.pagination-lg` or `.pagination-sm` for
|
||||||
{% example html %}
|
{% example html %}
|
||||||
<nav>
|
<nav>
|
||||||
<ul class="pagination pagination-lg">
|
<ul class="pagination pagination-lg">
|
||||||
<li>
|
<li class="page-item">
|
||||||
<a href="#" aria-label="Previous">
|
<a class="page-link" href="#" aria-label="Previous">
|
||||||
<span aria-hidden="true">«</span>
|
<span aria-hidden="true">«</span>
|
||||||
<span class="sr-only">Previous</span>
|
<span class="sr-only">Previous</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#">1</a></li>
|
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
||||||
<li><a href="#">2</a></li>
|
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||||
<li><a href="#">3</a></li>
|
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||||
<li>
|
<li class="page-item">
|
||||||
<a href="#" aria-label="Next">
|
<a class="page-link" href="#" aria-label="Next">
|
||||||
<span aria-hidden="true">»</span>
|
<span aria-hidden="true">»</span>
|
||||||
<span class="sr-only">Next</span>
|
<span class="sr-only">Next</span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -115,17 +115,17 @@ Fancy larger or smaller pagination? Add `.pagination-lg` or `.pagination-sm` for
|
||||||
{% example html %}
|
{% example html %}
|
||||||
<nav>
|
<nav>
|
||||||
<ul class="pagination pagination-sm">
|
<ul class="pagination pagination-sm">
|
||||||
<li>
|
<li class="page-item">
|
||||||
<a href="#" aria-label="Previous">
|
<a class="page-link" href="#" aria-label="Previous">
|
||||||
<span aria-hidden="true">«</span>
|
<span aria-hidden="true">«</span>
|
||||||
<span class="sr-only">Previous</span>
|
<span class="sr-only">Previous</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#">1</a></li>
|
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
||||||
<li><a href="#">2</a></li>
|
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||||
<li><a href="#">3</a></li>
|
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||||
<li>
|
<li class="page-item">
|
||||||
<a href="#" aria-label="Next">
|
<a class="page-link" href="#" aria-label="Next">
|
||||||
<span aria-hidden="true">»</span>
|
<span aria-hidden="true">»</span>
|
||||||
<span class="sr-only">Next</span>
|
<span class="sr-only">Next</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -4,48 +4,24 @@
|
||||||
margin-top: $spacer-y;
|
margin-top: $spacer-y;
|
||||||
margin-bottom: $spacer-y;
|
margin-bottom: $spacer-y;
|
||||||
@include border-radius();
|
@include border-radius();
|
||||||
|
}
|
||||||
|
|
||||||
> li {
|
.page-item {
|
||||||
display: inline; // Remove list-style and block-level defaults
|
display: inline; // Remove list-style and block-level defaults
|
||||||
|
|
||||||
> a,
|
&:first-child {
|
||||||
> span {
|
.page-link {
|
||||||
position: relative;
|
margin-left: 0;
|
||||||
float: left; // Collapse white-space
|
@include border-left-radius($border-radius);
|
||||||
padding: $pagination-padding-y $pagination-padding-x;
|
|
||||||
margin-left: -1px;
|
|
||||||
line-height: $line-height;
|
|
||||||
color: $pagination-color;
|
|
||||||
text-decoration: none;
|
|
||||||
background-color: $pagination-bg;
|
|
||||||
border: $pagination-border-width solid $pagination-border-color;
|
|
||||||
}
|
}
|
||||||
&:first-child {
|
}
|
||||||
> a,
|
&:last-child {
|
||||||
> span {
|
.page-link {
|
||||||
margin-left: 0;
|
@include border-right-radius($border-radius);
|
||||||
@include border-left-radius($border-radius);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&:last-child {
|
|
||||||
> a,
|
|
||||||
> span {
|
|
||||||
@include border-right-radius($border-radius);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> li > a,
|
&.active .page-link {
|
||||||
> li > span {
|
|
||||||
@include hover-focus {
|
|
||||||
color: $pagination-hover-color;
|
|
||||||
background-color: $pagination-hover-bg;
|
|
||||||
border-color: $pagination-hover-border;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
> .active > a,
|
|
||||||
> .active > span {
|
|
||||||
@include plain-hover-focus {
|
@include plain-hover-focus {
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
color: $pagination-active-color;
|
color: $pagination-active-color;
|
||||||
|
@ -55,19 +31,34 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> .disabled {
|
&.disabled .page-link {
|
||||||
> span,
|
@include plain-hover-focus {
|
||||||
> a {
|
color: $pagination-disabled-color;
|
||||||
@include plain-hover-focus {
|
cursor: $cursor-disabled;
|
||||||
color: $pagination-disabled-color;
|
background-color: $pagination-disabled-bg;
|
||||||
cursor: $cursor-disabled;
|
border-color: $pagination-disabled-border;
|
||||||
background-color: $pagination-disabled-bg;
|
|
||||||
border-color: $pagination-disabled-border;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.page-link {
|
||||||
|
position: relative;
|
||||||
|
float: left; // Collapse white-space
|
||||||
|
padding: $pagination-padding-y $pagination-padding-x;
|
||||||
|
margin-left: -1px;
|
||||||
|
line-height: $line-height;
|
||||||
|
color: $pagination-color;
|
||||||
|
text-decoration: none;
|
||||||
|
background-color: $pagination-bg;
|
||||||
|
border: 1px solid $pagination-border;
|
||||||
|
|
||||||
|
@include hover-focus {
|
||||||
|
color: $pagination-hover-color;
|
||||||
|
background-color: $pagination-hover-bg;
|
||||||
|
border-color: $pagination-hover-border;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sizing
|
// Sizing
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
// Pagination
|
// Pagination
|
||||||
|
|
||||||
@mixin pagination-size($padding-vertical, $padding-horizontal, $font-size, $line-height, $border-radius) {
|
@mixin pagination-size($padding-vertical, $padding-horizontal, $font-size, $line-height, $border-radius) {
|
||||||
> li {
|
.page-link {
|
||||||
> a,
|
padding: $padding-vertical $padding-horizontal;
|
||||||
> span {
|
font-size: $font-size;
|
||||||
padding: $padding-vertical $padding-horizontal;
|
line-height: $line-height;
|
||||||
font-size: $font-size;
|
}
|
||||||
line-height: $line-height;
|
|
||||||
}
|
.page-item {
|
||||||
&:first-child {
|
&:first-child {
|
||||||
> a,
|
.page-link {
|
||||||
> span {
|
|
||||||
@include border-left-radius($border-radius);
|
@include border-left-radius($border-radius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&:last-child {
|
&:last-child {
|
||||||
> a,
|
.page-link {
|
||||||
> span {
|
|
||||||
@include border-right-radius($border-radius);
|
@include border-right-radius($border-radius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue