aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Rebert <[email protected]>2015-11-29 21:47:49 -0800
committerChris Rebert <[email protected]>2015-11-29 21:47:49 -0800
commit548834e87f9e91c6e885d695deda55efc06dacf1 (patch)
tree42a42157264bc0b120a3c12a20d3932f630bba90
parent23d7b7fe429762847871c3ce8679922dd600e3c9 (diff)
parenta8dc4812a49d8467e8642abb510b523a9a51cd48 (diff)
downloadbootstrap-548834e87f9e91c6e885d695deda55efc06dacf1.tar.xz
bootstrap-548834e87f9e91c6e885d695deda55efc06dacf1.zip
Merge pull request #18340 from twbs/responsive-pulls
Add responsive float classes
-rw-r--r--docs/_includes/nav-home.html4
-rw-r--r--docs/components/list-group.md6
-rw-r--r--docs/components/navbar.md10
-rw-r--r--docs/components/utilities.md26
-rw-r--r--docs/content/images.md8
-rw-r--r--docs/examples/album/index.html2
-rw-r--r--docs/examples/carousel/index.html2
-rw-r--r--docs/examples/dashboard/index.html4
-rw-r--r--docs/examples/narrow-jumbotron/index.html2
-rw-r--r--docs/examples/navbar/index.html2
-rw-r--r--docs/examples/offcanvas/index.html2
-rw-r--r--docs/examples/tooltip-viewport/index.html4
-rw-r--r--docs/migration.md5
-rw-r--r--scss/_utilities.scss18
14 files changed, 53 insertions, 42 deletions
diff --git a/docs/_includes/nav-home.html b/docs/_includes/nav-home.html
index e4bae8be7..69609286e 100644
--- a/docs/_includes/nav-home.html
+++ b/docs/_includes/nav-home.html
@@ -1,6 +1,6 @@
<header class="navbar navbar-light navbar-static-top bd-navbar" role="banner">
{% comment %}
- <nav class="nav navbar-nav pull-right">
+ <nav class="nav navbar-nav pull-xs-right">
<div class="nav-item dropdown">
<a class="nav-item nav-link dropdown-toggle" href="#" id="bd-versions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
v{{ site.current_version }}
@@ -25,7 +25,7 @@
{% endcomment %}
<div class="clearfix">
- <button class="navbar-toggler pull-right hidden-sm-up" type="button" data-toggle="collapse" data-target="#bd-main-nav">
+ <button class="navbar-toggler pull-xs-right hidden-sm-up" type="button" data-toggle="collapse" data-target="#bd-main-nav">
&#9776;
</button>
<a class="navbar-brand hidden-sm-up" href="{{ site.baseurl }}/">
diff --git a/docs/components/list-group.md b/docs/components/list-group.md
index 7a8f1d06f..5dbcca2d5 100644
--- a/docs/components/list-group.md
+++ b/docs/components/list-group.md
@@ -31,15 +31,15 @@ Add labels to any list group item to show unread counts, activity, etc.
{% example html %}
<ul class="list-group">
<li class="list-group-item">
- <span class="label label-default label-pill pull-right">14</span>
+ <span class="label label-default label-pill pull-xs-right">14</span>
Cras justo odio
</li>
<li class="list-group-item">
- <span class="label label-default label-pill pull-right">2</span>
+ <span class="label label-default label-pill pull-xs-right">2</span>
Dapibus ac facilisis in
</li>
<li class="list-group-item">
- <span class="label label-default label-pill pull-right">1</span>
+ <span class="label label-default label-pill pull-xs-right">1</span>
Morbi leo risus
</li>
</ul>
diff --git a/docs/components/navbar.md b/docs/components/navbar.md
index 4db9f788a..7cc75a952 100644
--- a/docs/components/navbar.md
+++ b/docs/components/navbar.md
@@ -17,7 +17,7 @@ Here's what you need to know before getting started with the navbar:
- Navbars require a wrapping `.navbar` and a [color scheme](#color-schemes).
- Navbars and their contents are fluid by default. Use [optional containers](#containers) to limit their horizontal width.
-- Use `.pull-left` and `.pull-right` to quickly align sub-components.
+- Use `.pull-*-left` and `.pull-*-right` to quickly align sub-components.
- Ensure accessibility by using a `<nav>` element or, if using a more generic element such as a `<div>`, add a `role="navigation"` to every navbar to explicitly identify it as a landmark region for users of assistive technologies.
## Supported content
@@ -48,7 +48,7 @@ Here's an example of all the sub-components included in a default, light navbar:
<a class="nav-link" href="#">About</a>
</li>
</ul>
- <form class="form-inline navbar-form pull-right">
+ <form class="form-inline navbar-form pull-xs-right">
<input class="form-control" type="text" placeholder="Search">
<button class="btn btn-success-outline" type="submit">Search</button>
</form>
@@ -78,7 +78,7 @@ Here are some examples to show what we mean.
<a class="nav-link" href="#">About</a>
</li>
</ul>
- <form class="form-inline navbar-form pull-right">
+ <form class="form-inline navbar-form pull-xs-right">
<input class="form-control" type="text" placeholder="Search">
<button class="btn btn-info-outline" type="submit">Search</button>
</form>
@@ -99,7 +99,7 @@ Here are some examples to show what we mean.
<a class="nav-link" href="#">About</a>
</li>
</ul>
- <form class="form-inline navbar-form pull-right">
+ <form class="form-inline navbar-form pull-xs-right">
<input class="form-control" type="text" placeholder="Search">
<button class="btn btn-secondary-outline" type="submit">Search</button>
</form>
@@ -120,7 +120,7 @@ Here are some examples to show what we mean.
<a class="nav-link" href="#">About</a>
</li>
</ul>
- <form class="form-inline navbar-form pull-right">
+ <form class="form-inline navbar-form pull-xs-right">
<input class="form-control" type="text" placeholder="Search">
<button class="btn btn-primary-outline" type="submit">Search</button>
</form>
diff --git a/docs/components/utilities.md b/docs/components/utilities.md
index 7f3a5cc8d..693053a72 100644
--- a/docs/components/utilities.md
+++ b/docs/components/utilities.md
@@ -178,25 +178,25 @@ Use a generic close icon for dismissing content like modals and alerts. **Be sur
</button>
{% endexample %}
-## Floats
+## Responsive floats
-Float an element to the left or right with a class. `!important` is included to avoid specificity issues. Classes can also be used as mixins.
+These utility classes float an element to the left or right, or disable floating, based on the current viewport size using the [CSS `float` property](https://developer.mozilla.org/en-US/docs/Web/CSS/float). `!important` is included to avoid specificity issues. These use the same viewport width breakpoints as the grid system.
+
+Two similar non-responsive mixins (`pull-left` and `pull-right`) are also available.
{% example html %}
-<div class="pull-left">Float left</div>
-<div class="pull-right">Float right</div>
+<div class="pull-xs-left">Float left on all viewport sizes</div>
+<div class="pull-xs-right">Float right on all viewport sizes</div>
+<div class="pull-xs-none">Don't float on all viewport sizes</div>
+
+<div class="pull-sm-left">Float left on viewports sized SM (small) or wider</div>
+<div class="pull-md-left">Float left on viewports sized MD (medium) or wider</div>
+<div class="pull-lg-left">Float left on viewports sized LG (large) or wider</div>
+<div class="pull-xl-left">Float left on viewports sized XL (extra-large) or wider</div>
{% endexample %}
{% highlight scss %}
-// Classes
-.pull-left {
- float: left !important;
-}
-.pull-right {
- float: right !important;
-}
-
-// Usage as mixins
+// Related simple non-responsive mixins
.element {
@include pull-left;
}
diff --git a/docs/content/images.md b/docs/content/images.md
index fc37a761a..937394553 100644
--- a/docs/content/images.md
+++ b/docs/content/images.md
@@ -50,13 +50,13 @@ Add classes to an `<img>` element to easily style images in any project.
Align images with the [helper float classes]({{ site.baseurl }}/components/utilities/#floats) or [text alignment classes]({{ site.baseurl }}/components/utilities/#text-alignment). A simple centering class can also be used for `block` level images.
<div class="bd-example bd-example-images">
- <img data-src="holder.js/200x200" class="img-rounded pull-left" alt="A generic square placeholder image with rounded corners">
- <img data-src="holder.js/200x200" class="img-rounded pull-right" alt="A generic square placeholder image with rounded corners">
+ <img data-src="holder.js/200x200" class="img-rounded pull-xs-left" alt="A generic square placeholder image with rounded corners">
+ <img data-src="holder.js/200x200" class="img-rounded pull-xs-right" alt="A generic square placeholder image with rounded corners">
</div>
{% highlight html %}
-<img src="..." class="img-rounded pull-left" alt="...">
-<img src="..." class="img-rounded pull-right" alt="...">
+<img src="..." class="img-rounded pull-xs-left" alt="...">
+<img src="..." class="img-rounded pull-xs-right" alt="...">
{% endhighlight %}
<div class="bd-example bd-example-images">
diff --git a/docs/examples/album/index.html b/docs/examples/album/index.html
index 228f81198..d21ed1d40 100644
--- a/docs/examples/album/index.html
+++ b/docs/examples/album/index.html
@@ -104,7 +104,7 @@
<footer class="text-muted">
<div class="container">
- <p class="pull-right">
+ <p class="pull-xs-right">
<a href="#">Back to top</a>
</p>
<p>Album example is &copy; Bootstrap, but please download and customize it for yourself!</p>
diff --git a/docs/examples/carousel/index.html b/docs/examples/carousel/index.html
index e4a492991..01f0081a8 100644
--- a/docs/examples/carousel/index.html
+++ b/docs/examples/carousel/index.html
@@ -164,7 +164,7 @@
<!-- FOOTER -->
<footer>
- <p class="pull-right"><a href="#">Back to top</a></p>
+ <p class="pull-xs-right"><a href="#">Back to top</a></p>
<p>&copy; 2014 Company, Inc. &middot; <a href="#">Privacy</a> &middot; <a href="#">Terms</a></p>
</footer>
diff --git a/docs/examples/dashboard/index.html b/docs/examples/dashboard/index.html
index 08a91898e..87c507c3d 100644
--- a/docs/examples/dashboard/index.html
+++ b/docs/examples/dashboard/index.html
@@ -29,13 +29,13 @@
</button>
<a class="navbar-brand" href="#">Project name</a>
<div id="navbar">
- <nav class="nav navbar-nav pull-left">
+ <nav class="nav navbar-nav pull-xs-left">
<a class="nav-item nav-link" href="#">Dashboard</a>
<a class="nav-item nav-link" href="#">Settings</a>
<a class="nav-item nav-link" href="#">Profile</a>
<a class="nav-item nav-link" href="#">Help</a>
</nav>
- <form class="navbar-form pull-right">
+ <form class="navbar-form pull-xs-right">
<input type="text" class="form-control" placeholder="Search...">
</form>
</div>
diff --git a/docs/examples/narrow-jumbotron/index.html b/docs/examples/narrow-jumbotron/index.html
index f0d4e0ac0..210daf5f7 100644
--- a/docs/examples/narrow-jumbotron/index.html
+++ b/docs/examples/narrow-jumbotron/index.html
@@ -23,7 +23,7 @@
<div class="container">
<div class="header clearfix">
<nav>
- <ul class="nav nav-pills pull-right">
+ <ul class="nav nav-pills pull-xs-right">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
diff --git a/docs/examples/navbar/index.html b/docs/examples/navbar/index.html
index 67447ad70..029ce8ed2 100644
--- a/docs/examples/navbar/index.html
+++ b/docs/examples/navbar/index.html
@@ -41,7 +41,7 @@
<a class="nav-link" href="#">About</a>
</li>
</ul>
- <form class="form-inline navbar-form pull-right">
+ <form class="form-inline navbar-form pull-xs-right">
<input class="form-control" type="text" placeholder="Search">
<button class="btn btn-success-outline" type="submit">Search</button>
</form>
diff --git a/docs/examples/offcanvas/index.html b/docs/examples/offcanvas/index.html
index b1e133e21..cf12623b3 100644
--- a/docs/examples/offcanvas/index.html
+++ b/docs/examples/offcanvas/index.html
@@ -35,7 +35,7 @@
<div class="row row-offcanvas row-offcanvas-right">
<div class="col-xs-12 col-sm-9">
- <p class="pull-right hidden-sm-up">
+ <p class="pull-xs-right hidden-sm-up">
<button type="button" class="btn btn-primary btn-sm" data-toggle="offcanvas">Toggle nav</button>
</p>
<div class="jumbotron">
diff --git a/docs/examples/tooltip-viewport/index.html b/docs/examples/tooltip-viewport/index.html
index 50fa795cf..1edd38d67 100644
--- a/docs/examples/tooltip-viewport/index.html
+++ b/docs/examples/tooltip-viewport/index.html
@@ -20,7 +20,7 @@
<body>
- <button class="btn btn-secondary pull-right tooltip-bottom" title="This should be shifted to the left">Shift Left</button>
+ <button class="btn btn-secondary pull-xs-right tooltip-bottom" title="This should be shifted to the left">Shift Left</button>
<button class="btn btn-secondary tooltip-bottom" title="This should be shifted to the right">Shift Right</button>
<button class="btn btn-secondary tooltip-right" title="This should be shifted down">Shift Down</button>
@@ -30,7 +30,7 @@
<button class="btn btn-secondary tooltip-viewport-bottom" title="This should be shifted to the left">Shift Left</button>
<button class="btn btn-secondary tooltip-viewport-right" title="This should be shifted down">Shift Down</button>
- <button class="btn btn-secondary pull-right tooltip-viewport-bottom" title="This should be shifted to the right">Shift Right</button>
+ <button class="btn btn-secondary pull-xs-right tooltip-viewport-bottom" title="This should be shifted to the right">Shift Right</button>
<button class="btn btn-secondary tooltip-viewport-right btn-bottom" title="This should be shifted up">Shift Up</button>
</div>
diff --git a/docs/migration.md b/docs/migration.md
index 9ee4449fd..1e6b55a9c 100644
--- a/docs/migration.md
+++ b/docs/migration.md
@@ -128,6 +128,11 @@ Dropped entirely for the new card component.
- Renamed `.item` to `.carousel-item`.
+### Utilities
+
+- Added `.pull-{left,right,none}-{xs,sm,md,lg,xl}` classes for responsive floats
+- Removed `.pull-left` and `.pull-right` since they're redundant to `.pull-left-xs` and `.pull-right-xs`
+
## Documentation
Our documentation received an upgrade across the board as well. Here's the low down:
diff --git a/scss/_utilities.scss b/scss/_utilities.scss
index dfe718ec9..7c67b9095 100644
--- a/scss/_utilities.scss
+++ b/scss/_utilities.scss
@@ -10,12 +10,18 @@
@include center-block();
}
-.pull-right {
- @include pull-right();
-}
-
-.pull-left {
- @include pull-left();
+@each $breakpoint in map-keys($grid-breakpoints) {
+ @include media-breakpoint-up($breakpoint) {
+ .pull-#{$breakpoint}-left {
+ @include pull-left();
+ }
+ .pull-#{$breakpoint}-right {
+ @include pull-right();
+ }
+ .pull-#{$breakpoint}-none {
+ float: none !important;
+ }
+ }
}