Media Queries (PC-side, mobile-side layouts)

Source: Internet
Author: User

Media query Syntax:

1. Inline notation: Must have spaces after and
@media screen and (min-width:960px//Judging browser size conditions) {
Body{background:red}//General style
}

2. External wording: When the screen meets the criteria to connect the href CSS file
<link= ' stylesheet ' media= ' screen and (min-width:960) ' href= ' xx.css '/>
<link= ' stylesheet ' media= ' screen and (min-width:960) and (max-width:1960) ' href= ' xx.css '/>


Media queries display different interfaces on different screens in two ways:
1. Write a different style after the braces in different media queries are determined
2. Write two of the same HTML internal content, through the media query to determine the interface, show one, hide another

1 <!DOCTYPE HTML>2 <HTML>3 <HeadLang= "en">4 <MetaCharSet= "UTF-8">5 <title></title>6 <style>7 *{8 margin:0;9 padding:0;Ten } One . Big{                 /*1*/ A width:1000px; - Outline:1px solid #000; - margin:Auto; the Color:#fff; - } - . Big>div{ - width:50%; + Height:200px; - Outline:1px dashed Yellow; + background:Orange; A float: Left; at } - . Big2{                            /*2*/ - width:600px; - Outline:1px solid #000; - margin:Auto; - Color:#fff; in Display:None; - } to . Big2>div{ + width:100%; - Height:200px; the Outline:1px dashed Yellow; * background:Lightpink; $ Clear:both;Panax Notoginseng } - @media screen and (max-width:640px){ the . Big{display:None} + . Big2{Display:Block} A } the </style> + </Head> - <Body> $ <Divclass= "Big"> $ <Div>1</Div> - <Div>2</Div> - <Div>3</Div> the <Div>4</Div> - <Div>5</Div>Wuyi <Div>6</Div> the </Div> -  Wu <Divclass= "Big2"> - <Div>1</Div> About <Div>2</Div> $ <Div>3</Div> - <Div>4</Div> - <Div>5</Div> - <Div>6</Div> A </Div> + </Body> the </HTML>

Media Queries (PC-side, mobile-side layouts)

Related Article

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.