Media queries allow for custom CSS based on a number of conditions—ratios, widths, display type, etc—but usually focuses around min-width
and max-width
.
- Modify the width of column in our grid
- Stack elements instead of float wherever necessary
- Resize headings and text to be more appropriate for devices
Use media queries responsibly and only as a start to your mobile audiences. For larger projects, do consider dedicated code bases and not layers of media queries.
Supported devices
Bootstrap supports a handful of media queries in a single file to help make your projects more appropriate on different devices and screen resolutions. Here's what's included:
Label |
Layout width |
Column width |
Gutter width |
Large display |
1200px and up |
70px |
30px |
Default |
980px and up |
60px |
20px |
Portrait tablets |
768px and above |
42px |
20px |
Phones to tablets |
767px and below |
Fluid columns, no fixed widths |
Phones |
480px and below |
Fluid columns, no fixed widths |
/* Large desktop */
@media (min-width: 1300px) { ... }
/* Portrait tablet to landscape and desktop */
@media (min-width: 768px) and (max-width: 1023px) { ... }
/* Landscape phone to portrait tablet */
@media (max-width: 767px) { ... }
/* Landscape phones and down */
@media (max-width: 599px) { ... }
Responsive utility classes
For faster mobile-friendly development, use these utility classes for showing and hiding content by device. Below is a table of the available classes and their effect on a given media query layout (labeled by device). They can be found in responsive.less
.
Class |
Phones 767px and below |
Tablets 979px to 768px |
Desktops Default |
.visible-phone |
Visible |
Hidden |
Hidden |
.visible-tablet |
Hidden |
Visible |
Hidden |
.visible-desktop |
Hidden |
Hidden |
Visible |
.hidden-phone |
Hidden |
Visible |
Visible |
.hidden-tablet |
Visible |
Hidden |
Visible |
.hidden-desktop |
Visible |
Visible |
Hidden |
When to use
Use on a limited basis and avoid creating entirely different versions of the same site. Instead, use them to complement each device's presentation. Responsive utilities should not be used with tables, and as such are not supported.
Responsive utilities test case
Resize your browser or load on different devices to test the above classes.
Visible on...
Green checkmarks indicate that class is visible in your current viewport.
- Phone✔ Phone
- Tablet✔ Tablet
- Desktop✔ Desktop
Hidden on...
Here, green checkmarks indicate that class is hidden in your current viewport.
- Phone✔ Phone
- Tablet✔ Tablet
- Desktop✔ Desktop