实现禁止页面缩放

  • 移动端用户缩放页面可能会导致页面布局错乱问题,这里添加禁止页面缩放,适配微信浏览器和手机浏览器
<!DOCTYPE html>
<html lang="">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <!-- iOS Safari专属适配:强制应用模式渲染,强化禁止缩放 -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    
    <!-- 通用移动浏览器适配:减少自动缩放干预 -->
    <meta name="HandheldFriendly" content="true">
    <meta name="MobileOptimized" content="320">
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title><%= htmlWebpackPlugin.options.title %></title>

    <style>
      /* 禁止双指缩放、双击缩放 */
      * {
        touch-action: pan-x pan-y; /* 仅允许平移,禁止缩放/旋转 */
        -ms-touch-action: pan-x pan-y; /* IE移动版兼容 */
      }
    </style>
  </head>
  <body>
    <noscript>
      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->
  </body>
</html>

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐