我正在一個網頁(Merlot 模板)中開發一個簡單的 GitPages 小程式(HTML/JavaScript/JQuery)。這一切都很好,除了當頁面以縱向模式(Android 或 iPhone)顯示在 Chrome 移動瀏覽器上時,它會以縮放模式出現。當我捏縮小它時,它很合適,但我每次都必須捏。
示例頁面在這里:https : //securityessentials.github.io/ThreeRandomWords/ThreeRandomWords.html。
我怎樣才能讓它自動縮小?
- 查爾斯
uj5u.com熱心網友回復:
https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag
<meta name="viewport" content="width=device-width, initial-scale=1">
此元標記應設定初始比例
uj5u.com熱心網友回復:
啊哈!感謝@rmbdeivis 的評論,這是一個解決方案:
在head部分(在 Git Pages 中表示 _includes/head_custom.html)我添加了以下內容來更改視口指令。如果這是在正文部分,則它不起作用-也許瀏覽器在開始決議正文時設定了視口。
<script>
// Fix template to make zooming work correctly in Chrome on mobile.
$('meta[name="viewport"').attr("content", "width=device-width, initial-scale=0.5, maximum-scale=5.0, minimum-scale=0.5");
</script>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/406963.html
標籤:
