html5禁止浏览器缩放网页大小 (实用)

延伸阅读:meta标签viewport详解
html5默认允许用户缩放页面,如果需要禁止缩放,我们需要将user-scalabel=0设置下,具体代码如下:
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" />
注意:meta在head里。

<!DOCTYPE HTML>
<style>
    body {
        margin: 0;
        padding: 0;
    }
</style>

<script>
    //window.onload = function () {
    //}
</script>

<html>
<head>
    <meta name="viewport" 
     content="width=device-width, initial-scale=1.0, maximum-scale=1.0, 
     user-scalable=0;"/>
    <title></title>
</head>
<body>
   ...
</body>
</html>



 

发布了214 篇原创文章 · 获赞 292 · 访问量 332万+

猜你喜欢

转载自blog.csdn.net/chelen_jak/article/details/103968781