CSS-Responsive layout usage

Source: Internet
Author: User

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

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.