如何使用元標(biāo)簽視口來設(shè)置大?。?/p>
無論輸入什么值,標(biāo)簽都會(huì)被忽略。
我認(rèn)為我錯(cuò)了,因?yàn)檫@個(gè)代碼被桌面和移動(dòng)瀏覽器忽略了
<meta name="viewport" content="width=920, initial-scale=1">
我錯(cuò)過了什么嗎? 如何將視口設(shè)置為特定的寬度?
示例代碼
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=920, initial-scale=1">
<script>
window.onload = function () {
var viewportWidth = window.innerWidth || document.documentElement.clientWidth;
var text = "Viewport width: " + viewportWidth + // 1536
"<br>screen.width: " + screen.width + // 1536
"<br>window.devicePixelRatio: " + window.devicePixelRatio + // 1.25
"<br>screen.width * devicePixelRatio: " + window.screen.width*window.devicePixelRatio // 1920
document.getElementById("info").innerHTML = text;
};
</script>
<style>
html, body {padding: 0px; margin: 0px;}
</style>
</head>
<body>
<h1 id="info"></h1>
<div id="screen"></div>
<div style="width: 1920px; height: 100px; background-color: yellow;">1920 x 100</div>
<br>
<img src="https://i.imgur.com/h1Vr7E4.png" alt="" srcset="">
</body>
</html>
上一篇mvc全局引用vue
下一篇nginx部署vue模塊