What is the grammatical composition of media queries in css3
The syntax of media query is "@media not|only mediatype and (expressions) {CSS code...;}"; media query can be composed of multiple media and can contain one or more expressions. The expression returns true or false depending on whether the condition is true.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
CSS3's multimedia queries inherit all the ideas of CSS2 multimedia types: instead of looking for device types, CSS3 displays adaptively according to settings.
Media queries can be used to detect many things, such as:
The width and height of the viewport(window)
The device Width and height
Orientation (horizontal screen, vertical screen of smartphone)
Resolution
Currently, many devices such as Apple phones, Android phones, tablets, etc. use multimedia queries.
Query syntax
@media not|only mediatype and (expressions) { CSS 代码...; }
Multimedia query consists of a variety of media and can contain one or more expressions. The expression is based on whether the condition is true. Returns true or false.
Media type
#If the specified multimedia type matches the device type, the query result returns true, and the document will be on the matching device Display the specified style effect.
Unless the not or only operators are used, all styles will adapt to display on all devices.
Value | Description |
---|---|
all | is used for All media devices |
for printers | |
screen | for computer screens, tablets , smartphones, etc. |
speech | for screen readers |
Media Function
Value | Description |
---|---|
aspect- ratio | Define the ratio of the width and height of the visible area of the page in the output device |
color | Define the number of color originals in each set of the output device . If it is not a color device, the value is equal to 0 |
color-index | The number of entries defined in the output device's color lookup table. If no color lookup table is used, the value is equal to 0 |
device-aspect-ratio | Defines the ratio of the visible width to height of the screen of the output device. |
device-height | Define the screen visible height of the output device. |
device-width | Define the visible width of the screen of the output device. |
height | Define the height of the visible area of the page in the output device. |
max-aspect-ratio | Defines the maximum ratio of the output device's screen visible width to height. |
max-color | Define the maximum number of color originals in each group of output devices. |
max-color-index | Defines the maximum number of entries in the output device's color lookup table. |
max-device-aspect-ratio | Defines the maximum ratio of the output device's screen visible width to height. |
max-device-height | Defines the maximum height visible on the screen of the output device. |
max-device-width | Define the maximum visible width of the screen of the output device. |
max-height | Define the maximum visible area height of the page in the output device. |
max-resolution | Define the maximum resolution of the device. |
max-width | Define the maximum visible area width of the page in the output device. |
min-device-width | Define the minimum visible width of the screen of the output device. |
min-device-height | Defines the minimum visible height of the screen of the output device. |
min-height | Define the minimum visible area height of the page in the output device. |
min-width | Define the minimum visible area width of the page in the output device. |
orientation | Defines whether the height of the visible area of the page in the output device is greater than or equal to the width. |
resolution | Define the resolution of the device. For example: 96dpi, 300dpi, 118dpcm |
width | Define the width of the visible area of the page in the output device. |
For example
The screen width is greater than 480px, and the font size is set to 16px.
@media screen and (min-width: 480px) { body { font-size:16px; } }
(Learning video sharing: css video tutorial)
The above is the detailed content of What is the grammatical composition of media queries in css3. For more information, please follow other related articles on the PHP Chinese website!

The fact that anchor positioning eschews HTML source order is so CSS-y because it's another separation of concerns between content and presentation.

Article discusses CSS margin property, specifically "margin: 40px 100px 120px 80px", its application, and effects on webpage layout.

The article discusses CSS border properties, focusing on customization, best practices, and responsiveness. Main argument: border-radius is most effective for responsive designs.

The article discusses CSS background properties, their uses in enhancing website design, and common mistakes to avoid. Key focus is on responsive design using background-size.

Article discusses CSS HSL colors, their use in web design, and advantages over RGB. Main focus is on enhancing design and accessibility through intuitive color manipulation.

The article discusses the use of comments in CSS, detailing single-line and multi-line comment syntaxes. It argues that comments enhance code readability, maintainability, and collaboration, but may impact website performance if not managed properly.

The article discusses CSS Selectors, their types, and usage for styling HTML elements. It compares ID and class selectors and addresses performance issues with complex selectors.

The article discusses CSS priority, focusing on inline styles having the highest specificity. It explains specificity levels, overriding methods, and debugging tools for managing CSS conflicts.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
