Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

ตั้งค่า Media Queries สำหรับกฎสไตล์ CSS ที่แตกต่างกันสำหรับอุปกรณ์ขนาดต่างๆ


ในการตั้งค่าการสืบค้นสื่อสำหรับกฎรูปแบบ CSS ต่างๆ คุณสามารถลองเรียกใช้โค้ดต่อไปนี้ -

ตัวอย่าง

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