【发布时间】:2014-01-10 17:33:31
【问题描述】:
根据屏幕尺寸显示不同的logo,不知道为什么320尺寸的手机(索尼爱立信WT19i)不能执行正确的样式表。
我使用 javascript window.innerWidth 和 window.innerHeight 检查屏幕宽度,它是 320x401。它加载 800 像素的 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;
}
}
【问题讨论】:
-
尝试将
<meta name="viewport" content="initial-scale:1.0" />添加到您的<head>。 -
在此处添加javascript并更好地使用
max-width,因为在max-device-width中您必须添加device-pixel-ratio
标签: css