2009-04-30 59 views
4

我想將樣式表專門應用於iPhone,而無需在服務器上或通過JavaScript進行瀏覽器嗅探(通過用戶代理字符串)。如何在沒有瀏覽器嗅探的情況下將樣式表應用於iPhone(而不是IE)?

我特別不希望Internet Explorer應用樣式表。蘋果公司建議採用一個iPhone專用的樣式表的代碼,即:

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

似乎會導致由IE 7和6

回答

15

使用蘋果的推薦代碼應用樣式表,但在條件註釋把它包從IE隱藏:

<!--[if !IE]><!--> 
<link media="only screen and (max-device-width: 480px)" href="small-device.css" type= "text/css" rel="stylesheet"> 
<!--<![endif]--> 

信貸我認爲Sitepoint’s iPhone development article這一點。

相關問題