Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

ปรับเว็บเพจเดิมให้รองรับ mobile ด้วย CSS

เพื่อ retrofit ใช้ CSS media queries อนุญาต stylesheets ต่างๆ สำหรับความสามารถเบราว์เซอร์ต่างกัน ข้อดีคือไม่ต้องเขียน server-side code

ต้องเพิ่ม detection code ใน script สำหรับจัดกลุ่มอุปกรณ์

Media queries จัดการอุปกรณ์ที่คุณไม่เคยรู้จัก

ตั้งค่าดังนี้:

@media handheld and (max-width: 480px),
screen and (max-device-width: 480px),
screen and (max-width: 600px) {
  body {
    color: blue;
  }
}