Home > Web Front-end > CSS Tutorial > How to use css @media attribute

How to use css @media attribute

silencement
Release: 2019-05-29 12:00:06
Original
3889 people have browsed it

How to use css @media attribute

css @media attribute definition and usage

Using @media query, 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.

Example

If the document width is less than 300 pixels, modify the background color (background-color)

@media screen and (max-width: 300px) {
    body {
        background-color:lightblue;
    }
}
Copy after login

Syntax

@media mediatype and|not|only (media feature) {
    CSS-Code;
}
Copy after login

You can also use different stylesheets for different media

<link rel="stylesheet" media="mediatype and|not|only (media feature)" href="mystylesheet.css">
Copy after login

Media type

How to use css @media attribute

The above is the detailed content of How to use css @media attribute. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template