[英]if clause in html with CSS tag max-device-width, is it possible?
我有一個Universal iOS Project ,在這個項目中,我必須在UIWebView中顯示一些本地存儲的html頁面。
要調整html內容的大小,我必須在html中使用標簽:
<meta name ="viewport" content = "width = 703, user-scalable=no "> \\for the iPad
和
<meta name ="viewport" content = "width = device-width, user-scalable=no "> \\for the iPhone
有沒有一種方法可以在html的標頭中添加以下內容:
if( max-device-width == 480) {
<meta name ="viewport" content = "width = device-width, user-scalable=no ">
}
else {
<meta name ="viewport" content = "width = 703, user-scalable=no ">
}
有沒有辦法用HTML或JS做到這一點? 我只有關於html和js的基本概念,因此對實現此目標的任何幫助將不勝感激。
謝謝!
您應該能夠查詢窗口的大小(盡管要小心, 請參閱this ),並將width值替換為從JavaScript結果中獲取的值。 請閱讀上述的quirksmode帖子。 [如果您真的擔心結果,可以考慮使用jQuery之類的javascript庫,該庫應為您處理所有瀏覽器情況。]“ user-scalable = no”可以附加到您設置的值后面內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.