2010-07-09 57 views
3

我想通過使用CSS ipad.This測試方向是css文件我用iPad的CSS定位

@media only screen and (device-width:768px) and(orientation:portrait) { 
    body { background: green; } 
} 


@media only screen and (device-width:768px) and(orientation:landscape) { 
    body { background: red; } 
} 

我不知道這是否會工作或沒有。我嘗試通過將設備寬度更改爲320px在iPhone模擬器中進行測試。但它不起作用。我需要改變這個CSS文件中的任何東西嗎? 這是我如何調用CSS在主頁

<link rel="stylesheet" type="text/css" href="iPad.css" />" 
+0

我找到了答案 – karthick 2011-02-10 14:06:40

+1

你介意與我們分享嗎? – acme 2011-06-14 15:05:23

+0

是的,請在下面發佈您的解決方案並接受您自己的答案。 – Sparky 2011-11-08 20:55:43

回答

3

我用這個CSS解決了這個問題。

@media only screen and (device-width:768px) and(orientation:portrait) { 
     body { background: green; } 
    } 


    @media only screen and (device-width:768px) and(orientation:landscape) { 
     body { background: red; } 
    } 
4

這是我使用的調用具有橫向和縱向樣式表樣式表:

<link rel="stylesheet" media="all and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape)" href="css/landscape.css"> 
<link rel="stylesheet" media="all and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)" href="css/portrait.css"> 

我也發現了這個鏈接,你這是相當幫助:

http://perishablepress.com/press/2010/10/20/target-iphone-and-ipad-with-css3-media-queries/