diff --git a/docs/assets/scss/docs.scss b/docs/assets/scss/docs.scss index 8d68e318796380cf449f4881a46fd375d796a083..bf16e82a5e9eb9d0dc57dd28a3ed88abcf2dcc0e 100644 --- a/docs/assets/scss/docs.scss +++ b/docs/assets/scss/docs.scss @@ -1244,10 +1244,7 @@ body { .visible-on, .hidden-on { .col-xs-6 { - .hidden-xs, - .hidden-sm, - .hidden-md, - .hidden-lg { + > .not-visible { color: #999; border: 1px solid #ddd; } @@ -1256,10 +1253,7 @@ body { .visible-on, .hidden-on { .col-xs-6 { - .visible-xs-block, - .visible-sm-block, - .visible-md-block, - .visible-lg-block { + .visible { color: #468847; background-color: #dff0d8; border: 1px solid #d6e9c6; @@ -1267,6 +1261,32 @@ body { } } +@include media-breakpoint-only(xs) { + .hidden-xs-only { + display: none !important; + } +} +@include media-breakpoint-only(sm) { + .hidden-sm-only { + display: none !important; + } +} +@include media-breakpoint-only(md) { + .hidden-md-only { + display: none !important; + } +} +@include media-breakpoint-only(lg) { + .hidden-lg-only { + display: none !important; + } +} +@include media-breakpoint-only(xl) { + .hidden-xl-only { + display: none !important; + } +} + // // Brand guidelines // diff --git a/docs/layout/media-queries.md b/docs/layout/media-queries.md index f5d66a4173c512a64f66bb4bdbe900e94b88d24d..d628b4589f2c606deb1996d6e319f71d2b101e00 100644 --- a/docs/layout/media-queries.md +++ b/docs/layout/media-queries.md @@ -7,48 +7,64 @@ Since Bootstrap is designed to be mobile-first, we employ media queries in our C ### Common queries -Bootstrap uses the following media query ranges in our source Sass files for key breakpoints in our layout, grid system, and components. +Bootstrap mainly uses the following media query ranges in our source Sass files for key breakpoints in our layout, grid system, and components. {% highlight scss %} -/* Extra small devices (phones, less than 768px) */ +/* Extra small devices (portrait phones, less than ???px) */ /* No media query since this is the default in Bootstrap */ -/* Small devices (tablets, 768px and up) */ -@media (min-width: @screen-sm-min) { ... } +/* Small devices (landscape phones, 34em and up) */ +@media (min-width: 34em) { ... } -/* Medium devices (desktops, 992px and up) */ -@media (min-width: @screen-md-min) { ... } +/* Medium devices (tablets, 48em and up) */ +@media (min-width: 48em) { ... } -/* Large devices (large desktops, 1200px and up) */ -@media (min-width: @screen-lg-min) { ... } -{% endhighlight %} +/* Large devices (desktops, 62em and up) */ +@media (min-width: 62em) { ... } -We occasionally expand on these media queries to include a <code>max-width</code> to limit CSS to a narrower set of devices. +/* Extra large devices (large desktops, 75em and up) */ +@media (min-width: 75em) { ... } +{% endhighlight %} +These media queries are available via Sass mixins: {% highlight scss %} -@media (max-width: @screen-xs-max) { ... } -@media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { ... } -@media (min-width: @screen-md-min) and (max-width: @screen-md-max) { ... } -@media (min-width: @screen-lg-min) { ... } +@include media-breakpoint-up(xs) { ... } +@include media-breakpoint-up(sm) { ... } +@include media-breakpoint-up(md) { ... } +@include media-breakpoint-up(lg) { ... } +@include media-breakpoint-up(lxl) { ... } + +// Example usage: +@include media-breakpoint-up(sm) { + .some-class { + display: block; + } +} {% endhighlight %} -### Sass mixins +We occasionally use media queries that go in the other direction (the given screen size *or smaller*): +{% highlight scss %} +/* Extra small devices (portrait phones, less than 34em) */ +@media (max-width: 33.9em) { ... } + +/* Small devices (landscape phones, less than 48em) */ +@media (max-width: 47.9em) { ... } + +/* Medium devices (tablets, less than 62em) */ +@media (max-width: 61.9em) { ... } -The above media queries are also available via Sass mixins: +/* Large devices (desktops, less than 75em) */ +@media (max-width: 74.9em) { ... } + +/* Extra large devices (large desktops) */ +/* No media query since the extra-large breakpoint has no upper bound on its width */ +{% endhighlight %} +These media queries are available via Sass mixins: {% highlight scss %} -// List of mixins -@include media-xs { ... } -@include media-sm { ... } -@include media-sm-max { ... } -@include media-md { ... } -@include media-md-max { ... } -@include media-lg { ... } - -// Usage -@include media-xs { - .element { - display: block; - } -} +@include media-breakpoint-down(xs) { ... } +@include media-breakpoint-down(sm) { ... } +@include media-breakpoint-down(md) { ... } +@include media-breakpoint-down(lg) { ... } +@include media-breakpoint-down(lxl) { ... } {% endhighlight %} diff --git a/docs/layout/responsive-utilities.md b/docs/layout/responsive-utilities.md index 472682f6bfdb86bc84855a0da238378bcec26d83..a9dd4cdb0bc46fc793a049a3673a4e2d75749f30 100644 --- a/docs/layout/responsive-utilities.md +++ b/docs/layout/responsive-utilities.md @@ -9,7 +9,11 @@ Try to use these on a limited basis and avoid creating entirely different versio ## Available classes -Use a single or combination of the available classes for toggling content across viewport breakpoints. +* The `.hidden-*-up` classes hide the element when the viewport is at the given breakpoint or wider. For example, `.hidden-md-up` hides an element on medium, large, and extra-large viewports. +* The `.hidden-*-down` classes hide the element when the viewport is at the given breakpoint or smaller. For example, `.hidden-md-down` hides an element on extra-small, small, and medium viewports). +* There are no explicit "visible"/"show" responsive utility classes; you make an element visible by simply not hiding it at that breakpoint size. +* You can combine one `.hidden-*-up` class with one `.hidden-*-down` class to show an element only on a given interval of screen sizes. For example, `.hidden-sm-down.hidden-xl-up` shows the element only on medium and large viewports. Using multiple `.hidden-*-up` classes or multiple `.hidden-*-down` classes is redundant and pointless. +* These classes don't attempt to accommodate less common cases where an element's visibility can't be expressed as a single contiguous range of viewport breakpoint sizes; you will instead need to use custom CSS in such cases. <div class="table-responsive"> <table class="table table-bordered table-striped responsive-utilities"> @@ -18,112 +22,110 @@ Use a single or combination of the available classes for toggling content across <th></th> <th> Extra small devices - <small>Phones (<768px)</small> + <small>Portrait phones (<34em)</small> </th> <th> Small devices - <small>Tablets (≥768px)</small> + <small>Landscape phones (≥34em)</small> </th> <th> Medium devices - <small>Desktops (≥992px)</small> + <small>Tablets (≥48em)</small> </th> <th> Large devices - <small>Desktops (≥1200px)</small> + <small>Desktops (≥62em)</small> + </th> + <th> + Extra large devices + <small>Desktops (≥75em)</small> </th> </tr> </thead> <tbody> <tr> - <th scope="row"><code>.visible-xs-*</code></th> - <td class="is-visible">Visible</td> + <th scope="row"><code>.hidden-xs-down</code></th> <td class="is-hidden">Hidden</td> + <td class="is-visible">Visible</td> + <td class="is-visible">Visible</td> + <td class="is-visible">Visible</td> + <td class="is-visible">Visible</td> + </tr> + <tr> + <th scope="row"><code>.hidden-sm-down</code></th> <td class="is-hidden">Hidden</td> <td class="is-hidden">Hidden</td> + <td class="is-visible">Visible</td> + <td class="is-visible">Visible</td> + <td class="is-visible">Visible</td> </tr> <tr> - <th scope="row"><code>.visible-sm-*</code></th> + <th scope="row"><code>.hidden-md-down</code></th> <td class="is-hidden">Hidden</td> - <td class="is-visible">Visible</td> <td class="is-hidden">Hidden</td> <td class="is-hidden">Hidden</td> + <td class="is-visible">Visible</td> + <td class="is-visible">Visible</td> </tr> <tr> - <th scope="row"><code>.visible-md-*</code></th> + <th scope="row"><code>.hidden-lg-down</code></th> + <td class="is-hidden">Hidden</td> <td class="is-hidden">Hidden</td> <td class="is-hidden">Hidden</td> - <td class="is-visible">Visible</td> <td class="is-hidden">Hidden</td> + <td class="is-visible">Visible</td> </tr> <tr> - <th scope="row"><code>.visible-lg-*</code></th> + <th scope="row"><code>.hidden-xl-down</code></th> + <td class="is-hidden">Hidden</td> + <td class="is-hidden">Hidden</td> <td class="is-hidden">Hidden</td> <td class="is-hidden">Hidden</td> <td class="is-hidden">Hidden</td> - <td class="is-visible">Visible</td> </tr> - </tbody> - <tbody> <tr> - <th scope="row"><code>.hidden-xs</code></th> + <th scope="row"><code>.hidden-xs-up</code></th> + <td class="is-hidden">Hidden</td> + <td class="is-hidden">Hidden</td> + <td class="is-hidden">Hidden</td> + <td class="is-hidden">Hidden</td> <td class="is-hidden">Hidden</td> - <td class="is-visible">Visible</td> - <td class="is-visible">Visible</td> - <td class="is-visible">Visible</td> </tr> <tr> - <th scope="row"><code>.hidden-sm</code></th> + <th scope="row"><code>.hidden-sm-up</code></th> <td class="is-visible">Visible</td> <td class="is-hidden">Hidden</td> - <td class="is-visible">Visible</td> - <td class="is-visible">Visible</td> + <td class="is-hidden">Hidden</td> + <td class="is-hidden">Hidden</td> + <td class="is-hidden">Hidden</td> </tr> <tr> - <th scope="row"><code>.hidden-md</code></th> + <th scope="row"><code>.hidden-md-up</code></th> <td class="is-visible">Visible</td> <td class="is-visible">Visible</td> <td class="is-hidden">Hidden</td> - <td class="is-visible">Visible</td> + <td class="is-hidden">Hidden</td> + <td class="is-hidden">Hidden</td> </tr> <tr> - <th scope="row"><code>.hidden-lg</code></th> + <th scope="row"><code>.hidden-lg-up</code></th> <td class="is-visible">Visible</td> <td class="is-visible">Visible</td> <td class="is-visible">Visible</td> <td class="is-hidden">Hidden</td> - </tr> - </tbody> - </table> -</div> - -As of v3.2.0, the `.visible-*-*` classes for each breakpoint come in three variations, one for each CSS `display` property value listed below. - -<div class="table-responsive"> - <table class="table table-bordered table-striped"> - <thead> - <tr> - <th>Group of classes</th> - <th>CSS <code>display</code></th> - </tr> - </thead> - <tbody> - <tr> - <td><code>.visible-*-block</code></td> - <td><code>display: block;</code></td> - </tr> - <tr> - <td><code>.visible-*-inline</code></td> - <td><code>display: inline;</code></td> + <td class="is-hidden">Hidden</td> </tr> <tr> - <td><code>.visible-*-inline-block</code></td> - <td><code>display: inline-block;</code></td> + <th scope="row"><code>.hidden-xl-up</code></th> + <td class="is-visible">Visible</td> + <td class="is-visible">Visible</td> + <td class="is-visible">Visible</td> + <td class="is-visible">Visible</td> + <td class="is-hidden">Hidden</td> </tr> </tbody> </table> </div> -<p>So, for extra small (<code>xs</code>) screens for example, the available <code>.visible-*-*</code> classes are: <code>.visible-xs-block</code>, <code>.visible-xs-inline</code>, and <code>.visible-xs-inline-block</code>.</p> <h2 id="responsive-utilities-print">Print classes</h2> <p>Similar to the regular responsive classes, use these for toggling content for print.</p> @@ -131,20 +133,26 @@ As of v3.2.0, the `.visible-*-*` classes for each breakpoint come in three varia <table class="table table-bordered table-striped responsive-utilities"> <thead> <tr> - <th>Classes</th> + <th>Class</th> <th>Browser</th> <th>Print</th> </tr> </thead> <tbody> <tr> - <th> - <code>.visible-print-block</code><br> - <code>.visible-print-inline</code><br> - <code>.visible-print-inline-block</code> - </th> + <th><code>.visible-print-block</code></th> <td class="is-hidden">Hidden</td> - <td class="is-visible">Visible</td> + <td class="is-visible">Visible<br>(as <code>display: block</code>)</td> + </tr> + <tr> + <th><code>.visible-print-inline</code></th> + <td class="is-hidden">Hidden</td> + <td class="is-visible">Visible<br>(as <code>display: inline</code>)</td> + </tr> + <tr> + <th><code>.visible-print-inline-block</code></th> + <td class="is-hidden">Hidden</td> + <td class="is-visible">Visible<br>(as <code>display: inline-block</code>)</td> </tr> <tr> <th><code>.hidden-print</code></th> @@ -159,106 +167,63 @@ As of v3.2.0, the `.visible-*-*` classes for each breakpoint come in three varia Resize your browser or load on different devices to test the responsive utility classes. -### Visible on... - Green checkmarks indicate the element **is visible** in your current viewport. <div class="row responsive-utilities-test visible-on"> <div class="col-xs-6 col-sm-3"> - <span class="hidden-xs">Extra small</span> - <span class="visible-xs-block">✔ Visible on x-small</span> + <span class="hidden-sm-up visible">✔ Visible on extra small</span> + <span class="hidden-xs-down not-visible">Extra small</span> </div> <div class="col-xs-6 col-sm-3"> - <span class="hidden-sm">Small</span> - <span class="visible-sm-block">✔ Visible on small</span> + <span class="hidden-md-up visible">✔ Visible on small or narrower</span> + <span class="hidden-sm-down not-visible">Small or narrower</span> </div> - <div class="clearfix visible-xs-block"></div> <div class="col-xs-6 col-sm-3"> - <span class="hidden-md">Medium</span> - <span class="visible-md-block">✔ Visible on medium</span> + <span class="hidden-lg-up visible">✔ Visible on medium or narrower</span> + <span class="hidden-md-down not-visible">Medium or narrower</span> </div> <div class="col-xs-6 col-sm-3"> - <span class="hidden-lg">Large</span> - <span class="visible-lg-block">✔ Visible on large</span> + <span class="hidden-xl-up visible">✔ Visible on large or narrower</span> + <span class="hidden-lg-down not-visible">Large or narrower</span> </div> </div> <div class="row responsive-utilities-test visible-on"> - <div class="col-xs-6"> - <span class="hidden-xs hidden-sm">Extra small and small</span> - <span class="visible-xs-block visible-sm-block">✔ Visible on x-small and small</span> - </div> - <div class="col-xs-6"> - <span class="hidden-md hidden-lg">Medium and large</span> - <span class="visible-md-block visible-lg-block">✔ Visible on medium and large</span> - </div> - <div class="clearfix visible-xs-block"></div> - <div class="col-xs-6"> - <span class="hidden-xs hidden-md">Extra small and medium</span> - <span class="visible-xs-block visible-md-block">✔ Visible on x-small and medium</span> - </div> - <div class="col-xs-6"> - <span class="hidden-sm hidden-lg">Small and large</span> - <span class="visible-sm-block visible-lg-block">✔ Visible on small and large</span> - </div> - <div class="clearfix visible-xs-block"></div> - <div class="col-xs-6"> - <span class="hidden-xs hidden-lg">Extra small and large</span> - <span class="visible-xs-block visible-lg-block">✔ Visible on x-small and large</span> - </div> - <div class="col-xs-6"> - <span class="hidden-sm hidden-md">Small and medium</span> - <span class="visible-sm-block visible-md-block">✔ Visible on small and medium</span> - </div> -</div> - -### Hidden on... - -Here, green checkmarks also indicate the element **is hidden** in your current viewport. - -<div class="row responsive-utilities-test hidden-on"> <div class="col-xs-6 col-sm-3"> - <span class="hidden-xs">Extra small</span> - <span class="visible-xs-block">✔ Hidden on x-small</span> + <span class="hidden-xs-down visible">✔ Visible on small or wider</span> + <span class="hidden-sm-up not-visible">Small or wider</span> </div> <div class="col-xs-6 col-sm-3"> - <span class="hidden-sm">Small</span> - <span class="visible-sm-block">✔ Hidden on small</span> + <span class="hidden-sm-down visible">✔ Visible on medium or wider</span> + <span class="hidden-md-up not-visible">Medium or wider</span> </div> - <div class="clearfix visible-xs-block"></div> <div class="col-xs-6 col-sm-3"> - <span class="hidden-md">Medium</span> - <span class="visible-md-block">✔ Hidden on medium</span> + <span class="hidden-md-down visible">✔ Visible on large or wider</span> + <span class="hidden-lg-up not-visible">Large or wider</span> </div> <div class="col-xs-6 col-sm-3"> - <span class="hidden-lg">Large</span> - <span class="visible-lg-block">✔ Hidden on large</span> + <span class="hidden-lg-down visible">✔ Visible on extra large</span> + <span class="hidden-xl-up not-visible">Extra large</span> </div> </div> -<div class="row responsive-utilities-test hidden-on"> - <div class="col-xs-6"> - <span class="hidden-xs hidden-sm">Extra small and small</span> - <span class="visible-xs-block visible-sm-block">✔ Hidden on x-small and small</span> - </div> - <div class="col-xs-6"> - <span class="hidden-md hidden-lg">Medium and large</span> - <span class="visible-md-block visible-lg-block">✔ Hidden on medium and large</span> +<div class="row responsive-utilities-test visible-on"> + <div class="col-xs-6 col-sm-3"> + <span class="hidden-sm-up visible">✔ Your viewport is exactly extra small</span> + <span class="hidden-xs-down not-visible">Your viewport is NOT exactly extra small</span> </div> - <div class="clearfix visible-xs-block"></div> - <div class="col-xs-6"> - <span class="hidden-xs hidden-md">Extra small and medium</span> - <span class="visible-xs-block visible-md-block">✔ Hidden on x-small and medium</span> + <div class="col-xs-6 col-sm-3"> + <span class="hidden-xs-down hidden-md-up visible">✔ Your viewport is exactly small</span> + <span class="hidden-sm-only not-visible">Your viewport is NOT exactly small</span> </div> - <div class="col-xs-6"> - <span class="hidden-sm hidden-lg">Small and large</span> - <span class="visible-sm-block visible-lg-block">✔ Hidden on small and large</span> + <div class="col-xs-6 col-sm-3"> + <span class="hidden-sm-down hidden-lg-up visible">✔ Your viewport is exactly medium</span> + <span class="hidden-md-only not-visible">Your viewport is NOT exactly medium</span> </div> - <div class="clearfix visible-xs-block"></div> - <div class="col-xs-6"> - <span class="hidden-xs hidden-lg">Extra small and large</span> - <span class="visible-xs-block visible-lg-block">✔ Hidden on x-small and large</span> + <div class="col-xs-6 col-sm-3"> + <span class="hidden-md-down hidden-xl-up visible">✔ Your viewport is exactly large</span> + <span class="hidden-lg-only not-visible">Your viewport is NOT exactly large</span> </div> - <div class="col-xs-6"> - <span class="hidden-sm hidden-md">Small and medium</span> - <span class="visible-sm-block visible-md-block">✔ Hidden on small and medium</span> + <div class="col-xs-6 col-sm-3"> + <span class="hidden-lg-down visible">✔ Your viewport is exactly extra large</span> + <span class="hidden-xl-only not-visible">Your viewport is NOT exactly extra large</span> </div> </div> diff --git a/docs/migration.md b/docs/migration.md index c73fcaeae44df76e297ae6b36352d31fd552a7a8..a03be5dea66ac55716105a42d08746acafb68135 100644 --- a/docs/migration.md +++ b/docs/migration.md @@ -67,6 +67,8 @@ The following deprecated Less/SCSS variables have been removed in v4.0.0: * `@screen-xs`, `@screen-xs-min`. The extra small breakpoint has no lower bound, so these variables were logically absurd. Reformulate your expression in terms of `$screen-xs-max` instead. * `@grid-float-breakpoint` +The responsive utility classes have been overhauled. The old classes (`.hidden-xs` `.hidden-sm` `.hidden-md` `.hidden-lg` `.visible-xs-block` `.visible-xs-inline` `.visible-xs-inline-block` `.visible-sm-block` `.visible-sm-inline` `.visible-sm-inline-block` `.visible-md-block` `.visible-md-inline` `.visible-md-inline-block` `.visible-lg-block` `.visible-lg-inline` `.visible-lg-inline-block`) are gone. They have been replaced by `.hidden-xs-up` `.hidden-xs-down` `.hidden-sm-up` `.hidden-sm-down` `.hidden-md-up` `.hidden-md-down` `.hidden-lg-up` `.hidden-lg-down`. The `.hidden-*-up` classes hide the element when the viewport is at the given breakpoint or wider (e.g. `.hidden-md-up` hides an element on medium, large, and extra-large devices). The `.hidden-*-down` classes hide the element when the viewport is at the given breakpoint or smaller (e.g. `.hidden-md-down` hides an element on extra-small, small, and medium devices). Rather than using explicit `.visible-*` classes, you make an element visible by simply not hiding it at that screen size. You can combine one `.hidden-*-up` class with one `.hidden-*-down` class to show an element only on a given interval of screen sizes (e.g. `.hidden-sm-down.hidden-xl-up` shows the element only on medium and large devices). Note that the changes to the grid breakpoints in v4 means that you'll need to go one breakpoint larger to achieve the same results (e.g. `.hidden-md` is more similar to `.hidden-lg-down` than to `.hidden-md-down`). .The new responsive utility classes don't attempt to accommodate less common cases where an element's visibility can't be expressed as a single contiguous range of viewport sizes; you will instead need to use custom CSS in such cases. + ## Misc notes to prioritize - Removed the `min--moz-device-pixel-ratio` typo hack for retina media queries diff --git a/scss/_carousel.scss b/scss/_carousel.scss index 4802aea4c96584f0a710468ad3183a1d2646ab22..692ac938bb7321fea69c6b6fb048f68daba9ae14 100644 --- a/scss/_carousel.scss +++ b/scss/_carousel.scss @@ -218,7 +218,7 @@ // Scale up controls for tablets and up -@include media-sm { +@include media-breakpoint-up(sm) { // Scale up the controls a smidge .carousel-control { .icon-prev, diff --git a/scss/_dropdown.scss b/scss/_dropdown.scss index 99c7e79c95e397e48ba87a10917d98ea434e21d7..bd96d8f2252a77deb845646ab911a26385c625e6 100644 --- a/scss/_dropdown.scss +++ b/scss/_dropdown.scss @@ -195,7 +195,7 @@ // // TODO: remove? -// @include media-sm { +// @include media-breakpoint-up(sm) { // .navbar-right { // .dropdown-menu { // .dropdown-menu-right(); diff --git a/scss/_forms.scss b/scss/_forms.scss index dd2ff33df32ec912d472737d71a56318eab22839..f385c152f50124dab5c8484f3b47335e8a55b912 100644 --- a/scss/_forms.scss +++ b/scss/_forms.scss @@ -416,7 +416,7 @@ input[type="checkbox"] { .form-inline { // Kick in the inline - @include media-sm { + @include media-breakpoint-up(sm) { // Inline-block all the things for "inline" .form-group { display: inline-block; @@ -516,7 +516,7 @@ input[type="checkbox"] { // Reset spacing and right align labels, but scope to media queries so that // labels on narrow viewports stack the same as a default form example. - @include media-sm { + @include media-breakpoint-up(sm) { .control-label { padding-top: ($padding-base-vertical + .1); // Default padding plus a border margin-bottom: 0; @@ -537,14 +537,14 @@ input[type="checkbox"] { // Quick utility class for applying `.input-lg` and `.input-sm` styles to the // inputs and labels within a `.form-group`. .form-group-lg { - @include media-sm { + @include media-breakpoint-up(sm) { .control-label { padding-top: $padding-lg-vertical; } } } .form-group-sm { - @include media-sm { + @include media-breakpoint-up(sm) { .control-label { padding-top: ($padding-sm-vertical + .1); } diff --git a/scss/_grid.scss b/scss/_grid.scss index 1129cff6d024a926c36ff3179dd5a517c9f7b954..ed9f232af04d4cffe496e07dfddd5605b7d78b23 100644 --- a/scss/_grid.scss +++ b/scss/_grid.scss @@ -12,7 +12,7 @@ // For each breakpoint, define the maximum width of the container in a media query @each $breakpoint, $container-max-width in $container-max-widths { - @include media-breakpoint-min($breakpoint) { + @include media-breakpoint-up($breakpoint) { max-width: $container-max-width; } } diff --git a/scss/_jumbotron.scss b/scss/_jumbotron.scss index 61a5918b34e07b33d77aee6496287aebecfa4916..f826cd61603fe360e041879a26b816c3a60fe6d9 100644 --- a/scss/_jumbotron.scss +++ b/scss/_jumbotron.scss @@ -19,7 +19,7 @@ border-top-color: darken($jumbotron-bg, 10%); } -@include media-sm { +@include media-breakpoint-up(sm) { .jumbotron { padding: ($jumbotron-padding * 2) $jumbotron-padding; } diff --git a/scss/_mixins.scss b/scss/_mixins.scss index 5cba1afdf823af97d3718b13dbf52232fd345aa5..36f52a8932d0479e952fde921b9bc3977af49f8a 100644 --- a/scss/_mixins.scss +++ b/scss/_mixins.scss @@ -25,7 +25,6 @@ // Utilities @import "mixins/breakpoints"; -@import "mixins/media-queries"; @import "mixins/hide-text"; @import "mixins/image"; @import "mixins/label"; diff --git a/scss/_modal.scss b/scss/_modal.scss index 2566c3ef2de23824f71fcd38713f17208c3737dd..da3b90c0b4061864040f290879b78976daf1d760 100644 --- a/scss/_modal.scss +++ b/scss/_modal.scss @@ -126,7 +126,7 @@ } // Scale up the modal -@include media-sm { +@include media-breakpoint-up(sm) { // Automatically set modal's width for larger viewports .modal-dialog { width: $modal-md; @@ -140,6 +140,6 @@ .modal-sm { width: $modal-sm; } } -@include media-md { +@include media-breakpoint-up(md) { .modal-lg { width: $modal-lg; } } diff --git a/scss/_navbar.scss b/scss/_navbar.scss index b163dad9cd9499e3b9e9a2522a0347133dfaa289..2c12049a01fe94f54a2ae77f502186d9c077e4e0 100644 --- a/scss/_navbar.scss +++ b/scss/_navbar.scss @@ -14,7 +14,7 @@ margin-bottom: $navbar-margin-bottom; @include clearfix; - @include media-sm { + @include media-breakpoint-up(sm) { @include border-radius($navbar-border-radius); } } @@ -30,7 +30,7 @@ .navbar-static-top { z-index: $zindex-navbar; - @include media-sm { + @include media-breakpoint-up(sm) { @include border-radius(0); } } @@ -45,7 +45,7 @@ margin-bottom: 0; // override .navbar defaults // Undo the rounded corners - @include media-sm { + @include media-breakpoint-up(sm) { @include border-radius(0); } } @@ -119,7 +119,7 @@ @extend .form-inline; .form-group { - @include media-sm { + @include media-breakpoint-up(sm) { margin-bottom: 5px; &:last-child { @@ -132,7 +132,7 @@ // @include navbar-vertical-align($input-height-base); // Undo 100% width for pull classes - @include media-sm { + @include media-breakpoint-up(sm) { width: auto; padding-top: 0; padding-bottom: 0; @@ -181,7 +181,7 @@ .navbar-text { // @include navbar-vertical-align($line-height-computed); - @include media-sm { + @include media-breakpoint-up(sm) { float: left; margin-right: $navbar-padding-horizontal; margin-left: $navbar-padding-horizontal; @@ -197,7 +197,7 @@ // // Declared after the navbar components to ensure more specificity on the margins. -@include media-sm { +@include media-breakpoint-up(sm) { .navbar-left { @include pull-left(); } diff --git a/scss/_utilities-responsive.scss b/scss/_utilities-responsive.scss index 8c77d1833c88ec281c9075498b0a784334c661ab..837cda7b9a5ea944547de83cedde88ad2aaf598e 100644 --- a/scss/_utilities-responsive.scss +++ b/scss/_utilities-responsive.scss @@ -2,6 +2,19 @@ // Responsive: Utility classes // -------------------------------------------------- +@each $bp in map-keys($grid-breakpoints) { + .hidden-#{$bp}-up { + @include media-breakpoint-up($bp) { + display: none !important; + } + } + .hidden-#{$bp}-down { + @include media-breakpoint-down($bp) { + display: none !important; + } + } +} + // IE10 in Windows (Phone) 8 // @@ -23,98 +36,6 @@ } -.visible-xs-block, -.visible-xs-inline, -.visible-xs-inline-block, -.visible-sm-block, -.visible-sm-inline, -.visible-sm-inline-block, -.visible-md-block, -.visible-md-inline, -.visible-md-inline-block, -.visible-lg-block, -.visible-lg-inline, -.visible-lg-inline-block { - display: none !important; -} - -.visible-xs-block { - @include media-xs { - display: block !important; - } -} -.visible-xs-inline { - @include media-xs { - display: inline !important; - } -} -.visible-xs-inline-block { - @include media-xs { - display: inline-block !important; - } -} - -.visible-sm-block { - @include media-sm-max { - display: block !important; - } -} -.visible-sm-inline { - @include media-sm-max { - display: inline !important; - } -} -.visible-sm-inline-block { - @include media-sm-max { - display: inline-block !important; - } -} - -.visible-md-block { - @include media-md-max { - display: block !important; - } -} -.visible-md-inline { - @include media-md-max { - display: inline !important; - } -} -.visible-md-inline-block { - @include media-md-max { - display: inline-block !important; - } -} - -.visible-lg-block { - @include media-lg { - display: block !important; - } -} -.visible-lg-inline { - @include media-lg { - display: inline !important; - } -} -.visible-lg-inline-block { - @include media-lg { - display: inline-block !important; - } -} - -@include media-sm-max { - @include responsive-invisibility(".hidden-sm"); -} - -@include media-md-max { - @include responsive-invisibility(".hidden-md"); -} - -@include media-lg { - @include responsive-invisibility(".hidden-lg"); -} - - // Print utilities // // Media queries are placed on the inside to be mixin-friendly. diff --git a/scss/mixins/_breakpoints.scss b/scss/mixins/_breakpoints.scss index 71a15cd0430a21def001094952151d7574c2501b..232b9416f9553cd43e24a6f062abf571a2d20f4b 100644 --- a/scss/mixins/_breakpoints.scss +++ b/scss/mixins/_breakpoints.scss @@ -39,7 +39,8 @@ } // Media of at least the minimum breakpoint width. No query for the smallest breakpoint. -@mixin media-breakpoint-min($name, $breakpoints: $grid-breakpoints) { +// Makes the @content apply to the given breakpoint and wider. +@mixin media-breakpoint-up($name, $breakpoints: $grid-breakpoints) { $min: breakpoint-min($name, $breakpoints); @if $min { @media (min-width: $min) { @@ -51,7 +52,8 @@ } // Media of at most the maximum breakpoint width. No query for the largest breakpoint. -@mixin media-breakpoint-max($name, $breakpoints: $grid-breakpoints) { +// Makes the @content apply to the given breakpoint and narrower. +@mixin media-breakpoint-down($name, $breakpoints: $grid-breakpoints) { $max: breakpoint-max($name, $breakpoints); @if $max { @media (max-width: $max) { @@ -64,6 +66,7 @@ // Media between the breakpoint's minimum and maximum widths. // No minimum for the smallest breakpoint, and no maximum for the largest one. +// Makes the @content apply only to the given breakpoint, not viewports any wider or narrower. @mixin media-breakpoint-only($name, $breakpoints: $grid-breakpoints) { // Nested media query combination does not work in libsass yet // https://github.com/sass/libsass/issues/185 @@ -76,8 +79,8 @@ } } @else { // One of min or max is a no-op, so this branch is not affected by libsass#185 - @include media-breakpoint-min($name, $breakpoints) { - @include media-breakpoint-max($name, $breakpoints) { + @include media-breakpoint-up($name, $breakpoints) { + @include media-breakpoint-down($name, $breakpoints) { @content; } } diff --git a/scss/mixins/_grid-framework.scss b/scss/mixins/_grid-framework.scss index 0d346db57d81c987cb334869b581f61dc5d0db95..32705025e067073c77d928b77d1a47ac601bb292 100644 --- a/scss/mixins/_grid-framework.scss +++ b/scss/mixins/_grid-framework.scss @@ -19,7 +19,7 @@ @extend %grid-column; } } - @include media-breakpoint-min($breakpoint) { + @include media-breakpoint-up($breakpoint) { // Work around cross-media @extend (https://github.com/sass/sass/issues/1050) %grid-column-float-#{$breakpoint} { float: left; diff --git a/scss/mixins/_media-queries.scss b/scss/mixins/_media-queries.scss deleted file mode 100644 index 28130d2e7ea25f4b98ef5541a3a2da771be2729e..0000000000000000000000000000000000000000 --- a/scss/mixins/_media-queries.scss +++ /dev/null @@ -1,25 +0,0 @@ -// Media query mixins for default breakpoints - -@mixin media-xs() { - @include media-breakpoint-max(xs) { @content } -} - -@mixin media-sm() { - @include media-breakpoint-min(sm) { @content } -} - -@mixin media-sm-max() { - @include media-breakpoint-only(sm) { @content } -} - -@mixin media-md() { - @include media-breakpoint-min(md) { @content } -} - -@mixin media-md-max() { - @include media-breakpoint-only(md) { @content } -} - -@mixin media-lg() { - @include media-breakpoint-min(lg) { @content } -}