Front-end development Responsive Design Media query (bootstrap)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.