# Media Query Media query is widely used on mobile devices. You may need to frequently modify the application style based on the device type or specific features and device parameters \(such as the screen resolution\). To keep up with your requirements, the media query component provides the following features: 1. Allows you to design different layouts matching the device and application attributes. 2. Synchronously updates the application page layouts when your screen changes dynamically \(for example, in the event of screen splitting or landscape/portrait orientation switching\). >![](../../public_sys-resources/icon-note.gif) **NOTE:** >The **media** attribute uses the actual size, physical pixel, and screen resolution of the device by default. Do not confuse them with the configuration based on basic screen width 720 px. ## CSS Syntax Rules Use @media to import query statements. The rules are as follows: ``` @media [media-type] [and|not|only] [(media-feature)] { CSS-Code; } ``` Examples: @media screen and \(round-screen: true\) \{ … \} // The condition is met when the device screen is round. @media \(max-height: 800\) \{ … \} // Range query. CSS level 3 is used. @media \(height <= 800\) \{ ... \} // Range query. CSS level 4 is used, and the statement is equivalent to that of CSS level 3. @media screen and \(device-type: tv\) or \(resolution < 2\) \{ ... \} // Multi-condition query that contains the media type and multiple media features. ## Referencing Resources on a Page Use @import to import media query. The rule is as follows: ``` @import url [media-type] [and|not|only] [(media-feature)]; ``` Sample code: ``` @import '../common/style.css' screen and (min-width: 600) and (max-width: 1200); ``` ## Media Type
Less than or equal to, for example, screen and (50 <= height). |
|
Greater than or equal to, for example, screen and (600 >= height). |
|