Media query is a new feature of CSS3, which can be used for responsive design of the page; using "@media" query, it can be used to define failed styles for different media types, and can also be used for different screens. Size style sets different styles, the syntax is "@media [media medium] and|or (condition) and|or (condition){style}".
The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.
Is media query a new attribute of css3?
1. Media query is a new feature of css3, which can be used for responsive design of the page.
2. You can design multiple sets of different styles for different screens and different resolutions.
Media Query Syntax
@media [媒体介质] and|or (条件) and|or (条件){ //样式 .class{ } } //页面可见高度小于等于500px时,设置字体大小为10px @media screen and(max-height:500px){ .class{ font-size:10px } }
Using @media queries, you can define different styles for different media types.
@media can set different styles for different screen sizes, especially if you need to set up a responsive page, @media is very useful.
When you reset the browser size, the page will also be re-rendered based on the width and height of the browser.
CSS Syntax
@media not|only mediatype and (mediafeature and|or|not mediafeature) { CSS-Code; }
not, and, and only can be used to jointly construct complex media queries, and you can also combine multiple media queries into a single rule by separating them with commas.
not, only and and keyword meaning:
not: The not operator is used to negate media queries. If this condition is not met, it returns true, otherwise it returns false. . If present in a comma-separated list of queries, it will only negate the specific query to which it is applied. If you use the not operator, you must also specify the media type.
only: The only operator is used to apply a style only if the entire query matches, and is useful for preventing older browsers from applying the selected style. When only is not used, older browsers will simply interpret screen and (max-width: 500px) as screen, ignore the rest of the query, and apply its styles to all screens. If you use the only operator, you must also specify the media type.
, (comma) The comma is used to combine multiple media queries into a single rule. Each query in the comma-separated list is processed separately from other queries. Therefore, if any query in the list is true, the entire media statement returns true. In other words, the list behaves like the logical or operator.
and: The and operator is used to combine multiple media query rules into a single media query. When each query rule is true, the media query is true. It also Used to combine media functions with media types.
Media types describe general categories of devices. Unless the not or only logical operators are used, the media type is optional and the all type is (implicitly) applied.
You can also use different style files for different media:
<!-- 宽度大于 900px 的屏幕使用该样式 --> <link rel="stylesheet" media="screen and (min-width: 900px)" href="widescreen.css"> <!-- 宽度小于或等于 600px 的屏幕使用该样式 --> <link rel="stylesheet" media="screen and (max-width: 600px)" href="smallscreen.css">
(Learning video sharing: css video tutorial, html video tutorial)
The above is the detailed content of Is media query a new attribute in css3?. For more information, please follow other related articles on the PHP Chinese website!

在css中,可用list-style-type属性来去掉ul的圆点标记,语法为“ul{list-style-type:none}”;list-style-type属性可设置列表项标记的类型,当值为“none”可不定义标记,也可去除已有标记。

区别是:css是层叠样式表单,是将样式信息与网页内容分离的一种标记语言,主要用来设计网页的样式,还可以对网页各元素进行格式化;xml是可扩展标记语言,是一种数据存储语言,用于使用简单的标记描述数据,将文档分成许多部件并对这些部件加以标识。

在css中,可以利用cursor属性实现鼠标隐藏效果,该属性用于定义鼠标指针放在一个元素边界范围内时所用的光标形状,当属性值设置为none时,就可以实现鼠标隐藏效果,语法为“元素{cursor:none}”。

转换方法:1、给英文元素添加“text-transform: uppercase;”样式,可将所有的英文字母都变成大写;2、给英文元素添加“text-transform:capitalize;”样式,可将英文文本中每个单词的首字母变为大写。

在css中,rtl是“right-to-left”的缩写,是从右往左的意思,指的是内联内容从右往左依次排布,是direction属性的一个属性值;该属性规定了文本的方向和书写方向,语法为“元素{direction:rtl}”。

在css中,可以利用“font-style”属性设置i元素不是斜体样式,该属性用于指定文本的字体样式,当属性值设置为“normal”时,会显示元素的标准字体样式,语法为“i元素{font-style:normal}”。

在css3中,可以用“transform-origin”属性设置rotate的旋转中心点,该属性可更改转换元素的位置,第一个参数设置x轴的旋转位置,第二个参数设置y轴旋转位置,语法为“transform-origin:x轴位置 y轴位置”。


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

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

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
