Commit c8bfa7d3 authored by Chris Rebert's avatar Chris Rebert
Browse files

Merge pull request #54 from twbs/overhaul-responsive-visibility

Overhaul of responsive visibility classes
parents ff9c07f4 e651b48e
main cleanup-floating-forms cssvar-function dependabot/npm_and_yarn/stylelint-and-stylelint-config-twbs-bootstrap-15.3.0 extend-snippets feat/data-target floating-always-visible floating-labels-icons fod-main-banner form-controls-with-icons github/fork/719media/patch-13 github/fork/719media/patch-14 github/fork/719media/patch-9 github/fork/ChellyAhmed/fix-typo-reboot.md github/fork/ChellyAhmed/offcanvas-scroll-back github/fork/CtrlAltLilith/main github/fork/Elysiome/offcanvas-optional-window-resizing github/fork/JanSargsyan/main github/fork/LunicLynx/support-different-line-height-for-buttons github/fork/Psixodelik/main github/fork/Ronid1/ronid1/offcanvas_static_backdrop github/fork/RyanBerliner/tooltip-accessibility github/fork/SantiagoPVazquez/Feature-default-border-bottom-to-dropdown-item github/fork/Sir-Genius/utils github/fork/Sumit-Singh-8/main github/fork/Viktor-VERA2020/offcanvas-slide github/fork/Zivangu9/input-group-for-form-control-plaintext github/fork/alpadev/alpadev/call-dispose-on-component-reinstantiation github/fork/astagi/fix/tree-shake-modules github/fork/compnerd/dark-accordion-icon github/fork/derSascha/dropdown-dont-close-on-input-click github/fork/dev-ph1l/main github/fork/donquixote/issue-33861-utl-mixin github/fork/florianlacreuse/mixin-make-row-gutter-y github/fork/gregorw/main github/fork/iteggmbh/transitionend-dispose-race github/fork/jdelStrother/patch-1 github/fork/jonnysp/form-floating github/fork/jonnysp/independent-offcanvas github/fork/jonnysp/theme-dark-on-card-and-modal-fix github/fork/josefdlange/floating-label-placeholder-opacity github/fork/julien-deramond/enhance-change-version.js github/fork/julien-deramond/main-jd-fix-offset-content github/fork/julien-deramond/main-jd-issue-with-utitlies github/fork/julien-deramond/main-xmr-pa11y-ci-jd-add-hideElements github/fork/kyletsang/fix-tooltip-padding github/fork/lacutah/CheckboxCenteringDocumentation github/fork/lekoala/patch-3 github/fork/louismaximepiton/main-kld-lmp-collapse-proposal github/fork/louismaximepiton/main-lmp-card-inner-border-radius-fix github/fork/louismaximepiton/main-lmp-carousel-multiple-images github/fork/louismaximepiton/main-lmp-css-var-init github/fork/louismaximepiton/main-lmp-disabled-floating-label-fix github/fork/louismaximepiton/main-lmp-input-range-fix github/fork/louismaximepiton/main-lmp-shift-color github/fork/louismaximepiton/main-lmp-table-active-tr-fix github/fork/maciek-szn/switch github/fork/michael-roth/feature/19964-multiple-tab-targets github/fork/mistic100/dom-utils github/fork/nkdas91/accordion github/fork/nstungcom/fix-missing-modal-open-class github/fork/oraliahdz/animation-utilities github/fork/pine3ree/patch-7 github/fork/pouwerkerk/unindent-scss-docs-shortcode github/fork/smares/smares-no-scolling-on-modal-close github/fork/tgm-git/patch-1 gs-forms gs-toasts-with-animated-progress-bar gs/add-history-helper gs/change-version-dir-on-docs gs/data-must-set-onlu-one-instance gs/docs/fix-drop-down-error gs/event-handler-2 gs/make-docs-js-build gs/make-simple-attribute-toggler gs/popover-fix-doc gs/provide-steConfig-method gs/scrollspy-smoothscroll-option-use-browser-history gs/streamline-jqueryInterface gs/support-drop-down-in-navbar gs/test-js-generic-trigger gs/try-web-components gs/tweak-collapse-js-selector gs/use-event-handler-in-cocmponent gs/use-rollup-replace-for-version jo-docs-thanks-page jo-ssr-friendly logical-props-spacing-utils main-fod-disabled-form-check-label main-fod-nested-accordion main-fod-simpler-table-structure main-fod-table-separator main-fod-utilities-contrast main-jd-abbr-title main-jd-add-chips main-jd-add-doc-for-sass-custom-colors main-jd-add-enable-host-to-handle-web-components main-jd-browserstack-fine-tune main-jd-browserstack-updates main-jd-docs-consistent-usage-of-css-sections-step-2 main-jd-fix-docs-headers-in-white main-jd-fix-highlight-docs-border-radius main-jd-fix-placeholder-color-background-params-for-img-markup main-jd-glossary-experiment main-jd-postcss-drop-empty-css-vars main-jd-proto-doc-astro main-jd-skip-navigation-component main-jd-stackblitz-for-examples main-jd-upgrade-browserlistrc main-jd-use-host main-lmp-dark-theme-customization main-lmp-handle-scroll-target main-lmp-tab-fix main-mc-opensearch main-xmr-bundlewatch-action main-xmr-eslint-plugin-compat main-xmr-hugo-docs-vendor main-xmr-hugo-rm-ver main-xmr-linkinator-prod main-xmr-min-mangle main-xmr-pa11y-ci more-darkmode-examples nested-dropdowns patrickhlauke-issue37428 patrickhlauke-use-of-color-tweaks pr/34102 pr/37590 previous-next-docs-links sticky-thead utilities-functions-mixin v4-dev v4-dev-dropdown-hide-method v530-dev v6-postcss-custom-media v6-spinner-dots v6/gs/use-floating-ui-in-place-of-popper xmr/dev xmr/docs-png xmr/docs-svgs xmr/hugo-reorg-files xmr/js-2 xmr/markdownlint xmr/prepare-530-alpha2 xmr/xo v5.3.0-alpha1 v5.2.3 v5.2.2 v5.2.1 v5.2.0 v5.2.0-beta1 v5.1.3 v5.1.2 v5.1.1 v5.1.0 v5.0.2 v5.0.1 v5.0.0 v5.0.0-beta3 v5.0.0-beta2 v5.0.0-beta1 v5.0.0-alpha3 v5.0.0-alpha2 v5.0.0-alpha1 v4.6.2 v4.6.1 v4.6.0 v4.5.3 v4.5.2 v4.5.1 v4.5.0 v4.4.1 v4.4.0 v4.3.1 v4.3.0 v4.2.1 v4.2.0 v4.1.3 v4.1.2 v4.1.1 v4.1.0 v4.0.0 v4.0.0-beta.3 v4.0.0-beta.2 v4.0.0-beta v4.0.0-alpha.6 v4.0.0-alpha.5 v4.0.0-alpha.4 v4.0.0-alpha.3 v4.0.0-alpha.2 v4.0.0-alpha
48 merge requests!28721Hot test,!27561Adds font-weight-medium to font weight classes,!26437merge,!26197V4 dev xmr,!20778V4 dev,!20539Allow multiple modals,!18047#17986,!18988Blockquote border width,!20854Fixes 15534,!19272V4 dev xmr grunt html,!17218Issue 17066,!19581V4 fix popover,!18283Tether docs fix,!17229Include documentation for .navbar-static-top,!20493V4 dev display,!20636Fix docs for heading sizes,!19824blockquote-center,!22547Finished a new translation for bootstrap,!19534Docs 17264,!19533Npm deps,!22143Fix selectable disabled toggle radio buttons,!19084V4 rhythm,!18085Ie9 click comment,!22598test,!18829Add prefix to carousel classes,!18581Check getting started files for broken links - Issue 18568,!18067replace grunt-autoprefixer with gruntpostcss + autoprefixer,!20099V4.0.0 alpha.3,!20438V4 grid classes,!17307Vertical alignment on Bootstrap columns with equal height,!18477add utility color-contrast function,!18864Feature/navbar toggler support color schemes,!19602V4 palettes arun,!18311V4 dev xmr,!19448New pull request for testing,!19358XXL grid size,!19825.blockquote-center,!17508Fix usage of “its” and “it’s” (v4 docs),!25326Adjust examples,!23995Add back cursor: pointer for .btn-link,!23178Spinner,!19754Issue template,!19753Card img overlay padding,!19747Blockquote border width,!19580ExitStars,!18684Docs: change "Button" to "Go somewhere",!18661Docs: accessibility fix-up of collapsible content navbar, change site-wide main navbar,!17021v4
Showing with 212 additions and 311 deletions
+212 -311
...@@ -1244,10 +1244,7 @@ body { ...@@ -1244,10 +1244,7 @@ body {
.visible-on, .visible-on,
.hidden-on { .hidden-on {
.col-xs-6 { .col-xs-6 {
.hidden-xs, > .not-visible {
.hidden-sm,
.hidden-md,
.hidden-lg {
color: #999; color: #999;
border: 1px solid #ddd; border: 1px solid #ddd;
} }
...@@ -1256,10 +1253,7 @@ body { ...@@ -1256,10 +1253,7 @@ body {
.visible-on, .visible-on,
.hidden-on { .hidden-on {
.col-xs-6 { .col-xs-6 {
.visible-xs-block, .visible {
.visible-sm-block,
.visible-md-block,
.visible-lg-block {
color: #468847; color: #468847;
background-color: #dff0d8; background-color: #dff0d8;
border: 1px solid #d6e9c6; border: 1px solid #d6e9c6;
...@@ -1267,6 +1261,32 @@ body { ...@@ -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 // Brand guidelines
// //
......
...@@ -7,48 +7,64 @@ Since Bootstrap is designed to be mobile-first, we employ media queries in our C ...@@ -7,48 +7,64 @@ Since Bootstrap is designed to be mobile-first, we employ media queries in our C
### Common queries ### 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 %} {% 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 */ /* No media query since this is the default in Bootstrap */
/* Small devices (tablets, 768px and up) */ /* Small devices (landscape phones, 34em and up) */
@media (min-width: @screen-sm-min) { ... } @media (min-width: 34em) { ... }
/* Medium devices (desktops, 992px and up) */ /* Medium devices (tablets, 48em and up) */
@media (min-width: @screen-md-min) { ... } @media (min-width: 48em) { ... }
/* Large devices (large desktops, 1200px and up) */ /* Large devices (desktops, 62em and up) */
@media (min-width: @screen-lg-min) { ... } @media (min-width: 62em) { ... }
{% endhighlight %}
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 %} {% highlight scss %}
@media (max-width: @screen-xs-max) { ... } @include media-breakpoint-up(xs) { ... }
@media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { ... } @include media-breakpoint-up(sm) { ... }
@media (min-width: @screen-md-min) and (max-width: @screen-md-max) { ... } @include media-breakpoint-up(md) { ... }
@media (min-width: @screen-lg-min) { ... } @include media-breakpoint-up(lg) { ... }
@include media-breakpoint-up(lxl) { ... }
// Example usage:
@include media-breakpoint-up(sm) {
.some-class {
display: block;
}
}
{% endhighlight %} {% 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 %} {% highlight scss %}
// List of mixins @include media-breakpoint-down(xs) { ... }
@include media-xs { ... } @include media-breakpoint-down(sm) { ... }
@include media-sm { ... } @include media-breakpoint-down(md) { ... }
@include media-sm-max { ... } @include media-breakpoint-down(lg) { ... }
@include media-md { ... } @include media-breakpoint-down(lxl) { ... }
@include media-md-max { ... }
@include media-lg { ... }
// Usage
@include media-xs {
.element {
display: block;
}
}
{% endhighlight %} {% endhighlight %}
...@@ -9,7 +9,11 @@ Try to use these on a limited basis and avoid creating entirely different versio ...@@ -9,7 +9,11 @@ Try to use these on a limited basis and avoid creating entirely different versio
## Available classes ## 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"> <div class="table-responsive">
<table class="table table-bordered table-striped responsive-utilities"> <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 ...@@ -18,112 +22,110 @@ Use a single or combination of the available classes for toggling content across
<th></th> <th></th>
<th> <th>
Extra small devices Extra small devices
<small>Phones (&lt;768px)</small> <small>Portrait phones (&lt;34em)</small>
</th> </th>
<th> <th>
Small devices Small devices
<small>Tablets (&ge;768px)</small> <small>Landscape phones (&ge;34em)</small>
</th> </th>
<th> <th>
Medium devices Medium devices
<small>Desktops (&ge;992px)</small> <small>Tablets (&ge;48em)</small>
</th> </th>
<th> <th>
Large devices Large devices
<small>Desktops (&ge;1200px)</small> <small>Desktops (&ge;62em)</small>
</th>
<th>
Extra large devices
<small>Desktops (&ge;75em)</small>
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<th scope="row"><code>.visible-xs-*</code></th> <th scope="row"><code>.hidden-xs-down</code></th>
<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>
<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-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>
<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-hidden">Hidden</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> <td class="is-hidden">Hidden</td>
<td class="is-visible">Visible</td>
<td class="is-visible">Visible</td>
</tr> </tr>
<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-hidden">Hidden</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>
<td class="is-visible">Visible</td>
</tr> </tr>
<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-hidden">Hidden</td>
<td class="is-hidden">Hidden</td> <td class="is-hidden">Hidden</td>
<td class="is-visible">Visible</td>
</tr> </tr>
</tbody>
<tbody>
<tr> <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-hidden">Hidden</td>
<td class="is-visible">Visible</td>
<td class="is-visible">Visible</td>
<td class="is-visible">Visible</td>
</tr> </tr>
<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-visible">Visible</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> <td class="is-hidden">Hidden</td>
<td class="is-hidden">Hidden</td>
</tr> </tr>
<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-visible">Visible</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-hidden">Hidden</td>
<td class="is-hidden">Hidden</td>
</tr> </tr>
<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-visible">Visible</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>
</tr> <td class="is-hidden">Hidden</td>
</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>
</tr> </tr>
<tr> <tr>
<td><code>.visible-*-inline-block</code></td> <th scope="row"><code>.hidden-xl-up</code></th>
<td><code>display: inline-block;</code></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>
<td class="is-hidden">Hidden</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </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> <h2 id="responsive-utilities-print">Print classes</h2>
<p>Similar to the regular responsive classes, use these for toggling content for print.</p> <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 ...@@ -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"> <table class="table table-bordered table-striped responsive-utilities">
<thead> <thead>
<tr> <tr>
<th>Classes</th> <th>Class</th>
<th>Browser</th> <th>Browser</th>
<th>Print</th> <th>Print</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<th> <th><code>.visible-print-block</code></th>
<code>.visible-print-block</code><br>
<code>.visible-print-inline</code><br>
<code>.visible-print-inline-block</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<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>
<tr> <tr>
<th><code>.hidden-print</code></th> <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 ...@@ -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. 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. Green checkmarks indicate the element **is visible** in your current viewport.
<div class="row responsive-utilities-test visible-on"> <div class="row responsive-utilities-test visible-on">
<div class="col-xs-6 col-sm-3"> <div class="col-xs-6 col-sm-3">
<span class="hidden-xs">Extra small</span> <span class="hidden-sm-up visible">&#10004; Visible on extra small</span>
<span class="visible-xs-block">&#10004; Visible on x-small</span> <span class="hidden-xs-down not-visible">Extra small</span>
</div> </div>
<div class="col-xs-6 col-sm-3"> <div class="col-xs-6 col-sm-3">
<span class="hidden-sm">Small</span> <span class="hidden-md-up visible">&#10004; Visible on small or narrower</span>
<span class="visible-sm-block">&#10004; Visible on small</span> <span class="hidden-sm-down not-visible">Small or narrower</span>
</div> </div>
<div class="clearfix visible-xs-block"></div>
<div class="col-xs-6 col-sm-3"> <div class="col-xs-6 col-sm-3">
<span class="hidden-md">Medium</span> <span class="hidden-lg-up visible">&#10004; Visible on medium or narrower</span>
<span class="visible-md-block">&#10004; Visible on medium</span> <span class="hidden-md-down not-visible">Medium or narrower</span>
</div> </div>
<div class="col-xs-6 col-sm-3"> <div class="col-xs-6 col-sm-3">
<span class="hidden-lg">Large</span> <span class="hidden-xl-up visible">&#10004; Visible on large or narrower</span>
<span class="visible-lg-block">&#10004; Visible on large</span> <span class="hidden-lg-down not-visible">Large or narrower</span>
</div> </div>
</div> </div>
<div class="row responsive-utilities-test visible-on"> <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">&#10004; 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">&#10004; 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">&#10004; 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">&#10004; 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">&#10004; 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">&#10004; 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"> <div class="col-xs-6 col-sm-3">
<span class="hidden-xs">Extra small</span> <span class="hidden-xs-down visible">&#10004; Visible on small or wider</span>
<span class="visible-xs-block">&#10004; Hidden on x-small</span> <span class="hidden-sm-up not-visible">Small or wider</span>
</div> </div>
<div class="col-xs-6 col-sm-3"> <div class="col-xs-6 col-sm-3">
<span class="hidden-sm">Small</span> <span class="hidden-sm-down visible">&#10004; Visible on medium or wider</span>
<span class="visible-sm-block">&#10004; Hidden on small</span> <span class="hidden-md-up not-visible">Medium or wider</span>
</div> </div>
<div class="clearfix visible-xs-block"></div>
<div class="col-xs-6 col-sm-3"> <div class="col-xs-6 col-sm-3">
<span class="hidden-md">Medium</span> <span class="hidden-md-down visible">&#10004; Visible on large or wider</span>
<span class="visible-md-block">&#10004; Hidden on medium</span> <span class="hidden-lg-up not-visible">Large or wider</span>
</div> </div>
<div class="col-xs-6 col-sm-3"> <div class="col-xs-6 col-sm-3">
<span class="hidden-lg">Large</span> <span class="hidden-lg-down visible">&#10004; Visible on extra large</span>
<span class="visible-lg-block">&#10004; Hidden on large</span> <span class="hidden-xl-up not-visible">Extra large</span>
</div> </div>
</div> </div>
<div class="row responsive-utilities-test hidden-on"> <div class="row responsive-utilities-test visible-on">
<div class="col-xs-6"> <div class="col-xs-6 col-sm-3">
<span class="hidden-xs hidden-sm">Extra small and small</span> <span class="hidden-sm-up visible">&#10004; Your viewport is exactly extra small</span>
<span class="visible-xs-block visible-sm-block">&#10004; Hidden on x-small and small</span> <span class="hidden-xs-down not-visible">Your viewport is NOT exactly extra 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">&#10004; Hidden on medium and large</span>
</div> </div>
<div class="clearfix visible-xs-block"></div> <div class="col-xs-6 col-sm-3">
<div class="col-xs-6"> <span class="hidden-xs-down hidden-md-up visible">&#10004; Your viewport is exactly small</span>
<span class="hidden-xs hidden-md">Extra small and medium</span> <span class="hidden-sm-only not-visible">Your viewport is NOT exactly small</span>
<span class="visible-xs-block visible-md-block">&#10004; Hidden on x-small and medium</span>
</div> </div>
<div class="col-xs-6"> <div class="col-xs-6 col-sm-3">
<span class="hidden-sm hidden-lg">Small and large</span> <span class="hidden-sm-down hidden-lg-up visible">&#10004; Your viewport is exactly medium</span>
<span class="visible-sm-block visible-lg-block">&#10004; Hidden on small and large</span> <span class="hidden-md-only not-visible">Your viewport is NOT exactly medium</span>
</div> </div>
<div class="clearfix visible-xs-block"></div> <div class="col-xs-6 col-sm-3">
<div class="col-xs-6"> <span class="hidden-md-down hidden-xl-up visible">&#10004; Your viewport is exactly large</span>
<span class="hidden-xs hidden-lg">Extra small and large</span> <span class="hidden-lg-only not-visible">Your viewport is NOT exactly large</span>
<span class="visible-xs-block visible-lg-block">&#10004; Hidden on x-small and large</span>
</div> </div>
<div class="col-xs-6"> <div class="col-xs-6 col-sm-3">
<span class="hidden-sm hidden-md">Small and medium</span> <span class="hidden-lg-down visible">&#10004; Your viewport is exactly extra large</span>
<span class="visible-sm-block visible-md-block">&#10004; Hidden on small and medium</span> <span class="hidden-xl-only not-visible">Your viewport is NOT exactly extra large</span>
</div> </div>
</div> </div>
...@@ -67,6 +67,8 @@ The following deprecated Less/SCSS variables have been removed in v4.0.0: ...@@ -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. * `@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` * `@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 ## Misc notes to prioritize
- Removed the `min--moz-device-pixel-ratio` typo hack for retina media queries - Removed the `min--moz-device-pixel-ratio` typo hack for retina media queries
......
...@@ -218,7 +218,7 @@ ...@@ -218,7 +218,7 @@
// Scale up controls for tablets and up // Scale up controls for tablets and up
@include media-sm { @include media-breakpoint-up(sm) {
// Scale up the controls a smidge // Scale up the controls a smidge
.carousel-control { .carousel-control {
.icon-prev, .icon-prev,
......
...@@ -195,7 +195,7 @@ ...@@ -195,7 +195,7 @@
// //
// TODO: remove? // TODO: remove?
// @include media-sm { // @include media-breakpoint-up(sm) {
// .navbar-right { // .navbar-right {
// .dropdown-menu { // .dropdown-menu {
// .dropdown-menu-right(); // .dropdown-menu-right();
......
...@@ -416,7 +416,7 @@ input[type="checkbox"] { ...@@ -416,7 +416,7 @@ input[type="checkbox"] {
.form-inline { .form-inline {
// Kick in the inline // Kick in the inline
@include media-sm { @include media-breakpoint-up(sm) {
// Inline-block all the things for "inline" // Inline-block all the things for "inline"
.form-group { .form-group {
display: inline-block; display: inline-block;
...@@ -516,7 +516,7 @@ input[type="checkbox"] { ...@@ -516,7 +516,7 @@ input[type="checkbox"] {
// Reset spacing and right align labels, but scope to media queries so that // 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. // labels on narrow viewports stack the same as a default form example.
@include media-sm { @include media-breakpoint-up(sm) {
.control-label { .control-label {
padding-top: ($padding-base-vertical + .1); // Default padding plus a border padding-top: ($padding-base-vertical + .1); // Default padding plus a border
margin-bottom: 0; margin-bottom: 0;
...@@ -537,14 +537,14 @@ input[type="checkbox"] { ...@@ -537,14 +537,14 @@ input[type="checkbox"] {
// Quick utility class for applying `.input-lg` and `.input-sm` styles to the // Quick utility class for applying `.input-lg` and `.input-sm` styles to the
// inputs and labels within a `.form-group`. // inputs and labels within a `.form-group`.
.form-group-lg { .form-group-lg {
@include media-sm { @include media-breakpoint-up(sm) {
.control-label { .control-label {
padding-top: $padding-lg-vertical; padding-top: $padding-lg-vertical;
} }
} }
} }
.form-group-sm { .form-group-sm {
@include media-sm { @include media-breakpoint-up(sm) {
.control-label { .control-label {
padding-top: ($padding-sm-vertical + .1); padding-top: ($padding-sm-vertical + .1);
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
// For each breakpoint, define the maximum width of the container in a media query // For each breakpoint, define the maximum width of the container in a media query
@each $breakpoint, $container-max-width in $container-max-widths { @each $breakpoint, $container-max-width in $container-max-widths {
@include media-breakpoint-min($breakpoint) { @include media-breakpoint-up($breakpoint) {
max-width: $container-max-width; max-width: $container-max-width;
} }
} }
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
border-top-color: darken($jumbotron-bg, 10%); border-top-color: darken($jumbotron-bg, 10%);
} }
@include media-sm { @include media-breakpoint-up(sm) {
.jumbotron { .jumbotron {
padding: ($jumbotron-padding * 2) $jumbotron-padding; padding: ($jumbotron-padding * 2) $jumbotron-padding;
} }
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
// Utilities // Utilities
@import "mixins/breakpoints"; @import "mixins/breakpoints";
@import "mixins/media-queries";
@import "mixins/hide-text"; @import "mixins/hide-text";
@import "mixins/image"; @import "mixins/image";
@import "mixins/label"; @import "mixins/label";
......
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
} }
// Scale up the modal // Scale up the modal
@include media-sm { @include media-breakpoint-up(sm) {
// Automatically set modal's width for larger viewports // Automatically set modal's width for larger viewports
.modal-dialog { .modal-dialog {
width: $modal-md; width: $modal-md;
...@@ -140,6 +140,6 @@ ...@@ -140,6 +140,6 @@
.modal-sm { width: $modal-sm; } .modal-sm { width: $modal-sm; }
} }
@include media-md { @include media-breakpoint-up(md) {
.modal-lg { width: $modal-lg; } .modal-lg { width: $modal-lg; }
} }
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
margin-bottom: $navbar-margin-bottom; margin-bottom: $navbar-margin-bottom;
@include clearfix; @include clearfix;
@include media-sm { @include media-breakpoint-up(sm) {
@include border-radius($navbar-border-radius); @include border-radius($navbar-border-radius);
} }
} }
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
.navbar-static-top { .navbar-static-top {
z-index: $zindex-navbar; z-index: $zindex-navbar;
@include media-sm { @include media-breakpoint-up(sm) {
@include border-radius(0); @include border-radius(0);
} }
} }
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
margin-bottom: 0; // override .navbar defaults margin-bottom: 0; // override .navbar defaults
// Undo the rounded corners // Undo the rounded corners
@include media-sm { @include media-breakpoint-up(sm) {
@include border-radius(0); @include border-radius(0);
} }
} }
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
@extend .form-inline; @extend .form-inline;
.form-group { .form-group {
@include media-sm { @include media-breakpoint-up(sm) {
margin-bottom: 5px; margin-bottom: 5px;
&:last-child { &:last-child {
...@@ -132,7 +132,7 @@ ...@@ -132,7 +132,7 @@
// @include navbar-vertical-align($input-height-base); // @include navbar-vertical-align($input-height-base);
// Undo 100% width for pull classes // Undo 100% width for pull classes
@include media-sm { @include media-breakpoint-up(sm) {
width: auto; width: auto;
padding-top: 0; padding-top: 0;
padding-bottom: 0; padding-bottom: 0;
...@@ -181,7 +181,7 @@ ...@@ -181,7 +181,7 @@
.navbar-text { .navbar-text {
// @include navbar-vertical-align($line-height-computed); // @include navbar-vertical-align($line-height-computed);
@include media-sm { @include media-breakpoint-up(sm) {
float: left; float: left;
margin-right: $navbar-padding-horizontal; margin-right: $navbar-padding-horizontal;
margin-left: $navbar-padding-horizontal; margin-left: $navbar-padding-horizontal;
...@@ -197,7 +197,7 @@ ...@@ -197,7 +197,7 @@
// //
// Declared after the navbar components to ensure more specificity on the margins. // Declared after the navbar components to ensure more specificity on the margins.
@include media-sm { @include media-breakpoint-up(sm) {
.navbar-left { .navbar-left {
@include pull-left(); @include pull-left();
} }
......
...@@ -2,6 +2,19 @@ ...@@ -2,6 +2,19 @@
// Responsive: Utility classes // 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 // IE10 in Windows (Phone) 8
// //
...@@ -23,98 +36,6 @@ ...@@ -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 // Print utilities
// //
// Media queries are placed on the inside to be mixin-friendly. // Media queries are placed on the inside to be mixin-friendly.
......
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
} }
// Media of at least the minimum breakpoint width. No query for the smallest breakpoint. // 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); $min: breakpoint-min($name, $breakpoints);
@if $min { @if $min {
@media (min-width: $min) { @media (min-width: $min) {
...@@ -51,7 +52,8 @@ ...@@ -51,7 +52,8 @@
} }
// Media of at most the maximum breakpoint width. No query for the largest breakpoint. // 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); $max: breakpoint-max($name, $breakpoints);
@if $max { @if $max {
@media (max-width: $max) { @media (max-width: $max) {
...@@ -64,6 +66,7 @@ ...@@ -64,6 +66,7 @@
// Media between the breakpoint's minimum and maximum widths. // Media between the breakpoint's minimum and maximum widths.
// No minimum for the smallest breakpoint, and no maximum for the largest one. // 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) { @mixin media-breakpoint-only($name, $breakpoints: $grid-breakpoints) {
// Nested media query combination does not work in libsass yet // Nested media query combination does not work in libsass yet
// https://github.com/sass/libsass/issues/185 // https://github.com/sass/libsass/issues/185
...@@ -76,8 +79,8 @@ ...@@ -76,8 +79,8 @@
} }
} @else { } @else {
// One of min or max is a no-op, so this branch is not affected by libsass#185 // 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-up($name, $breakpoints) {
@include media-breakpoint-max($name, $breakpoints) { @include media-breakpoint-down($name, $breakpoints) {
@content; @content;
} }
} }
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
@extend %grid-column; @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) // Work around cross-media @extend (https://github.com/sass/sass/issues/1050)
%grid-column-float-#{$breakpoint} { %grid-column-float-#{$breakpoint} {
float: left; float: left;
......
// 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 }
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment