Nowadays, the screen resolution of computer monitors is developing towards higher and higher, but the resolution of mobile device terminals such as mobile phones cannot be that much higher. More and more websites are starting to adapt their pages to various resolutions, displaying basic content at small resolutions, full functions at large resolutions, and even multiple versions at multiple levels. 1. @media in CSS2 Although CSS2 supports the @media attribute, it can only implement a few functions and is generally only used to define special CSS for printing.
1.1 Examples // Set the font size for the display @media screen { BODY {font-size:12pt; } } // Set the font size for the printer @media print { @import "print.css" BODY {font-size:8pt;} } 2. @media in CSS3 The @media attribute has evolved into a kind of grammar: @media mediatype and|not|only (media feature) { CSS-sRules; }
Determine the media (object) type to achieve different displays. This feature allows CSS to act more precisely on different media types. 2.1 Examples body{background:blue;}/*width between 500px-800px + height between 100px-400px blue*/ @media screen and (max-width:500px){body{background:green;}}/*Green when width is less than 500px*/ @media screen and (min-width:800px){body{background:red;}}/*Red when width is greater than 800px*/ @media screen and (max-height:100px){body{background:yellow;}}/*Yellow when height is less than 100px*/ @media screen and (min-height:400px){body{background:pink;}}/*Pink when height is greater than 400px*/ 2.2 Media Characteristics
Summarize This concludes this article about using @media in CSS3 to achieve web page adaptation. For more relevant css3 media web page adaptation content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! |
>>: Vue implements nested routing method example
The scope of css is global. As the project gets b...
This article shares the specific code of jQuery t...
This article example shares the specific code of ...
We know that the commonly used events in JS are: ...
How to view version information under Linux, incl...
If a form field in a form is set to disabled, the ...
I saw a good idea and recorded it. I have used jQ...
Table of contents Stabilization Throttling: Anti-...
Table of contents Preface Project Design rear end...
Types of Indexes in MySQL Generally, they can be ...
The difference between replace into and insert in...
Table of contents 1. Overview 2. gdb debugging 2....
Table of contents Event Loop Browser environment ...
Before officially using Docker, let's first f...
Preface A few days ago, I came across the feature...