首页 > 解决方案 > 如何在 Angular webapp 的移动浏览器中禁用 IOS 双击缩放?(我什么都试过了)

问题描述

我试过了 :

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=0"/>


<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />

body {
  touch-action: manipulation !important;
}

没有任何效果,我仍然可以在 iOS 上双击 safari 和 chrome。

有任何想法吗 ?谢谢你。

标签: htmlcssiosangulargoogle-chrome

解决方案


全局禁用双击缩放的 CSS:

* {
  touch-action: manipulation;
}

编辑:

我在带有 IOS v14.4.2 的 iPhone 7 Plus 上对此进行了测试,它对我有用。

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>No double tap</title>
  <style>
    .no-double-tap {
      touch-action: manipulation;
    }
  </style>
</head>
<body>
  <h2>no double tap</h2>
  <img class="no-double-tap" src="https://picsum.photos/id/1/200/300">
  <h2>double tap</h2>
  <img src="https://picsum.photos/id/2/200/300">
</body>
</html>

推荐阅读