2013-02-16 49 views

回答

5

下面是我對此事的說明:對於任何設備 - 做它的屏幕尺寸和比你的研究,然後在你的樣式表對每個設備做一個@media查詢。

iPhone4的

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

(縱向或橫向)在iPad上

<link rel="stylesheet" media="all and (orientation:portrait)" href="portrait.css"> 
<link rel="stylesheet" media="all and (orientation:landscape)" href="landscape.css"> 

手機肖像

@media screen and (max-device-width: 480px) and (orientation: portrait){ 
/* some CSS here */ 
} 

手機景觀

@media screen and (max-device-width: 640px) and (orientation: landscape){ 
/* some CSS here */ 
} 

手機縱向或橫向

@media screen and (max-device-width: 640px){ 
    /* some CSS here */ 
} 

iPhone 4+縱向或橫向

@media screen and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2){ 
/* some CSS here */ 
} 

iPhone 5僅

@media only screen and (min-device-width: 640px) and (max-device-width: 1136px) and (- webkit-min-device-pixel-ratio: 2) { 
    /* styles here */ 
} 

iPhone < 5:長寬比

@media screen and (device-aspect-ratio: 2/3) {} 

片劑縱向或橫向

@media screen and (min-device-width: 768px) and (max-device-width: 1024px){ 
/* some CSS here */ 
} 

桌面

@media screen and (min-width: 1024px){ 
/* some CSS here */ 
} 

樣式只在兩種尺寸之間。

@media screen and (min-width: 319px) and (max-width: 1281px){} 

BTDUBS - 你知道WordPress有一個is_iphone()全球內置?

global $is_iphone; 
if ($is_iphone) { 
// do something if $is_iphone is true 
} 
+0

感謝本 - 但我要說的是,初始查詢更相關:什麼簡單的CSS的方法是有betw移動設備和筆記本電腦/臺式機的distinghuis從我的研究我的朋友 – 2013-02-20 12:05:37

+0

只有屏幕尺寸!如果您遇到其他問題,請在此發佈。 – BenRacicot 2013-02-20 16:22:51

+0

非常感謝!似乎媒體查詢「掌上電腦」看起來像一個選項,但沒有人實現它 – 2013-02-21 16:35:24

2

你可以使用@media查詢來解決你的問題,下面可能是你可以嘗試的東西。您還可以將設備方向作爲設置來定位設備,或者像下面那樣設置最大寬度,然後編寫您的CSS。希望這可以幫助。

@media screen and (max-device-width: 480px) { 
    .class { 
    background: #000; 
    } 
} 
相關問題