使用CSS3进行媒体查询

媒体查询针对不同尺寸的设备(例如手机,台式机等)使用不同的样式规则。

您可以尝试运行以下代码以使用CSS3实施媒体查询-

示例

<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>

以上是 使用CSS3进行媒体查询 的全部内容, 来源链接: utcz.com/z/326592.html

回到顶部