Home > Web Front-end > CSS Tutorial > Media queries to set different CSS style rules for different size devices

Media queries to set different CSS style rules for different size devices

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-08-30 23:57:03
forward
1159 people have browsed it

Media queries to set different CSS style rules for different size devices

To set media queries for different CSS style rules, you can try running the following code −

Example

Live demonstration

<html>
   <head>
      <style>
         body {
            background-color: lightpink;
         }
         @media screen and (max-width: 420px) {
            body {
               background-color: lightblue;
            }
         }
      </style>
   </head>
   <body>
      <p>If screen size is less than 420px, then it will show lightblue color, or else it will show light pink color</p>
   </body>
</html>
Copy after login

The above is the detailed content of Media queries to set different CSS style rules for different size devices. For more information, please follow other related articles on the PHP Chinese website!

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