Is media query a new attribute in css3?
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!

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics











Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-
