2015-11-04 86 views
0

我正在嘗試使用媒體查詢,但是當我轉到我的iPhone時它們不工作。當我調整我的瀏覽器窗口時,它工作正常。他們看起來像下面這樣:iPhone上的媒體查詢

@media (max-width: 480px){...} 

而且我已經包括在文件的頂部以下meta標籤:

<meta name="viewport" content="width=device-width, initial-scale=1.0"> 

任何想法,爲什麼它會無法正常工作?

+0

這會幫助你。 http://stackoverflow.com/questions/25759046/iphone-6-and-6-plus-media-queries –

回答

0

編輯

試試這個:

/* ----------- iPhone 4 and 4S ----------- */ 

/* Portrait and Landscape */ 
@media only screen 
    and (min-device-width: 320px) 
    and (max-device-width: 480px) 
    and (-webkit-min-device-pixel-ratio: 2) { 

} 

/* Portrait */ 
@media only screen 
    and (min-device-width: 320px) 
    and (max-device-width: 480px) 
    and (-webkit-min-device-pixel-ratio: 2) 
    and (orientation: portrait) { 
} 

/* Landscape */ 
@media only screen 
    and (min-device-width: 320px) 
    and (max-device-width: 480px) 
    and (-webkit-min-device-pixel-ratio: 2) 
    and (orientation: landscape) { 

} 

您可以使用this爲iPhone手機參考。