开发者

Detect and link different stylesheets for iphone 3 and iphone 4

开发者 https://www.devze.com 2023-04-01 10:56 出处:网络
I am trying to define different stylesheets for iphone 3 and iphone 4 this way <link href=\"css/style.css\" rel=\"stylesheet\" type=\"text/css\" />

I am trying to define different stylesheets for iphone 3 and iphone 4 this way

<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" media="all and (max-device-width: 320px)" href="iphone3.css" />
<link rel="stylesheet" media="all and (max-device-width: 640px)" href="iphone4.css" />

and both iphone3.css and iphone4.css have a body{display:none;} to test that they are working but in my iphone4 I still see the webiste,

what am I missing?

th开发者_Python百科anks!


This will target both iPhone 3 and 4:

@media only screen and (max-device-width: 480px){
    body{background:red;}
}

or

<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iphone3.css" />

You can use this query to then override the previous styles and target only iPhone 4:

@media only screen and (-webkit-min-device-pixel-ratio: 2){
    body{background:blue;}
}

or

<link rel="stylesheet" media="only screen and (-webkit-min-device-pixel-ratio: 2)" href="iphone4.css" />


@media only screen and (max-width: 480px){
    body{background:red;}
}
0

精彩评论

暂无评论...
验证码 换一张
取 消