1. Usage of inline styles
Use the style in the
<HeadLang= "en"> <MetaCharSet= "UTF-8"> <title>Example of a responsive layout</title> <style>@media screen and (min-width:800px){Body {Background-color:Red; }} @media screen and (max-width:800px){Body {Background-color:Blue;; } } </style></Head>
The 2 styles are used here: when the resolution is <=800, the background color is blue, and when the resolution is >=800, the background color is red;
2. Using a reference to an outer-chain style sheet
<Linkhref= "Css/responsive1.css"rel= "stylesheet"type= "Text/css"Media= "only screen and (min-width:800px)"> <Linkhref= "Css/responsive2.css"rel= "stylesheet"type= "Text/css"Media= "only screen and (max-width:800px)">
Here you have specified a different CSS file for different resolutions, and the effect is the same as above.
3. Declare the same in the same style file
<meta name= "viewport" content= "width = device-width,initial-scale=1"/> < href= "Css/responsive.css" rel= "stylesheet" type= "text /css "/>
Body { margin:0px auto;} @media screen and (max-width:600px) { body { background:blue; }} @media screen and (min-width:900px) { body { background:red; }}
This can only be declared in a file, and each style that needs to be set may be set individually.
Reference article http://www.cnblogs.com/lhb25/archive/2012/12/04/css3-media-queries.html
CSS-Responsive layout usage