根據屏幕尺寸顯示不同的標誌,不知道爲什麼尺寸爲320的手機(索尼愛立信WT19i)無法執行正確的樣式表。CSS不適用於小屏幕尺寸手機
我使用JavaScript window.innerWidth和window.innerHeight這是320x401檢查屏幕寬度。它加載800px的CSS。
@media screen {
body {
background-image:url('desktop.png') !important;
background-repeat:no-repeat !important;
background-attachment:fixed !important;
background-position:right bottom !important;
}
}
@media screen and (max-device-width: 320px) {
body {
background-image:url('320P.png') !important;
background-repeat:no-repeat !important;
background-attachment:fixed !important;
background-position:right bottom !important;
}
}
@media screen and (max-device-width: 800px) {
body {
background-image:url('800P.png') !important;
background-repeat:no-repeat !important;
background-attachment:fixed !important;
background-position:right bottom !important;
}
}
嘗試向您的「
」添加「'。 – Passerby在此處添加javascript並更好地使用'max-width',因爲在'max-device-width'中,您必須添加'device-pixel-ratio' – Pinal