2013-03-11 41 views
0

在WordPress的我的頭PHP我可以同時添加視口:可能使用width = device-width和meta name =「viewport」content =「width = 1024」?

<meta name="viewport" content="width=device-width" /> 

<meta name="viewport" content="width=1024" /> 

我希望能夠使用viewport width 1024everything顯示,除非你是低於移動設備的說x像素,然後使用width=device-width來代替。

這可能嗎?

感謝

+0

http://wordpress.org/extend/plugins/php-browser-detection /並且如果它是一個移動瀏覽器,'echo'這個好元! – JoDev 2013-03-11 13:16:48

回答

1

有了良好plugin,這將是這樣的:

<meta name="viewport" content="width=<?php echo (is_mobile()) ? "device-width" : "width=1024" ?>" /> 
+0

感謝喬,它的作品,但我的風格都在移動版本的地方,他們工作時,只使用設備寬度?正常的瀏覽器可以在1024.使用兒童主題基於二十二個,所以它的運行移動首先。我有以下媒體查詢:從所有移動樣式開始,然後是/ * 600像素的最小寬度。 */ 媒體屏幕和(最小寬度:600px)這撿iPad,在線ipad生成器顯示所有內容,但實際ipad只看到頁眉/頁腳顯示,因此爲什麼切換此寬度= 1024,然後最後一個媒體屏幕和(min-width:960px) – 2013-03-11 14:07:51

+0

對不起,但我不明白是什麼問題? 你不想根據瀏覽器的寬度來改變'viewport'屬性的值嗎? – JoDev 2013-03-11 14:39:55

+0

在ipad上查看時,頁眉和頁腳之間的內容消失,但在屏幕上的ipad模擬中查看它看起來不錯,這意味着使用螢火蟲找到問題並不好。因爲如果使用視口內容=「width = 1024」,ipad版本看起來沒問題我以爲我可以使用它,但這也影響到手機版本,我想要一個解決方案,允許手機使用初始的css(它的移動優先方法)使用設備寬度,但然後強制ipad和屏幕使用視口寬度1024.這是否使它更清晰?對不起,可能不太清楚,但我確實嘗試過。 – 2013-03-11 16:44:41

0

你可以試試下面的代碼

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

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

/* #### Mobile Phones Portrait or Landscape #### */ 
@media screen and (max-device-width: 640px){ 
/* some CSS here */ 
} 

/* #### iPhone 4+ Portrait or Landscape #### */ 
@media screen and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2){ 
/* some CSS here */ 
} 

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

/* #### Desktops #### */ 
@media screen and (min-width: 1024px){ 
/* some CSS here */ 
} 
相關問題