Media query can be based on the characteristics of the device display (viewport width, screen size, device direction-horizontal or vertical, etc.) for its CSS style
Why response design requires media queries. Because there is no CSS3 media query module, you cannot set specific CSS styles for device features (especially the viewport width)
Bootstrap.css file The last several lines, is about the media query code, the first time not to look at his source code, look at the following simple CSS sample codes:
body {
background-color:white;
}
@media screen and (max-width:960px) {body
{
background-color:red
}}
}
@media screen and (max-width:768px) {body
{
background-color:yellow
}}
}
@media screen and (max-width:550px) {body
{
background-color:green
}}
}
@media screen and (max-width:320px) {body
{
background-color:blue
}}
}
Defines the background color white for the element body, media query to see whether the current monitor screen, after the correct judge, then to see the size of current screens, according to different sizes overwrite the current body background color
The code above is the CSS3 file modeled after Bootstrap.
Media inquiries only CSS3, in fact, CSS2 when there is this
<link rel= "stylesheet" type= "text/css" media= "screen" href= "Screen.css" >
By importing the link label, the media query is judged, if the current device is a monitor, not a printer, and other devices, then import the Screen.css file, pay attention to the order of media and href, do not reverse
I have previously written about media to judge the print printer, so if it is a printer, import the relevant CSS file, you can add extra formatting when printing