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

WBOY
WBOYforward
2023-08-30 23:57:031110browse

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>

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:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete