Bootstrap

4.8 Media Queries

Contents

Overview

A media query is a “command” to tell the CSS to only apply the declarations to one display size.

To change something on mobile and tablet, add this to the bottom of your CSS file:



@media (max-width: 767px) {
	/* CSS is nested here */

}

How To

This example shows a set of CSS specifications for a jumbotron. The media query states additional style specifications that will only apply to the mobile size.

The background color changes to green on mobile, but the padding and margin remain the same.



.jumbotron{
	background-color:#cc0000;
	padding:10px;
	margin-top:20px
}

@media (max-width: 576px){
	.jumbotron{
		background-color:#00cc00;
	}
}

Grid Measurements

Bootstrap defines the following widths: