touch-action CSS property sets how an element's region can be manipulated by a touchscreen user (for example, by zooming features built into the browser).

/* Keyword values */
touch-action: auto;
touch-action: none;
touch-action: pan-x;
touch-action: pan-left;
touch-action: pan-right;
touch-action: pan-y;
touch-action: pan-up;
touch-action: pan-down;
touch-action: pinch-zoom;
touch-action: manipulation;
/* Global values */
touch-action: inherit;
touch-action: initial;
touch-action: unset;
					

By default, panning (scrolling) and pinching gestures are handled exclusively by the browser. An application using 指针事件 will receive a pointercancel event when the browser starts handling a touch gesture. By explicitly specifying which gestures should be handled by the browser, an application can supply its own behavior in pointermove and pointerup listeners for the remaining gestures. Applications using 触摸事件 disable the browser handling of gestures by calling preventDefault() , but should also use touch-action to ensure the browser knows the intent of the application before any event listeners have been invoked.

When a gesture is started, the browser intersects the touch-action values of the touched element and its ancestors, up to the one that implements the gesture (in other words, the first containing scrolling element). This means that in practice, touch-action is typically applied only to top-level elements which have some custom behavior, without needing to specify touch-action explicitly on any of that element's descendants.

After a gesture starts, changes to touch-action will not have any impact on the behavior of the current gesture.

句法

touch-action property may be specified as either:

auto

Enable browser handling of all panning and zooming gestures.

none

Disable browser handling of all panning and zooming gestures.

pan-x
Enable single-finger horizontal panning gestures. May be combined with pan-y , pan-up , pan-down and/or pinch-zoom .
pan-y
Enable single-finger vertical panning gestures. May be combined with pan-x , pan-left , pan-right and/or pinch-zoom .
manipulation
Enable panning and pinch zoom gestures, but disable additional non-standard gestures such as double-tap to zoom. Disabling double-tap to zoom removes the need for browsers to delay the generation of click events when the user taps the screen. This is an alias for " pan-x pan-y pinch-zoom " (which, for compatibility, is itself still valid).
pan-left , pan-right , pan-up , pan-down
Enable single-finger gestures that begin by scrolling in the given direction(s). Once scrolling has started, the direction may still be reversed. Note that scrolling "up" ( pan-up ) means that the user is dragging their finger downward on the screen surface, and likewise pan-left means the user is dragging their finger to the right. Multiple directions may be combined except when there is a simpler representation (for example, " pan-left pan-right " is invalid since " pan-x " is simpler, but " pan-left pan-down " is valid).
pinch-zoom
Enable multi-finger panning and zooming of the page. This may be combined with any of the pan- values.

可访问性关注

A declaration of touch-action: none; may inhibit operating a browser's zooming capabilities. This will prevent people experiencing low vision conditions from being able to read and understand page content.

形式定义

初始值 auto
适用于 all elements except: non-replaced inline elements, table rows, row groups, table columns, and column groups
继承 no
计算值 如指定
动画类型 discrete

形式句法

auto | none | [ [ pan-x | pan-left | pan-right ] || [ pan-y | pan-up | pan-down ] || pinch-zoom ] | manipulation
					

范例

Disabling all gestures

The most common usage is to disable all gestures on an element (and its non-scrollable descendants) that provides its own dragging and zooming behavior – such as a map or game surface.

HTML

<div id="map"></div>
					

CSS

#map {
  height: 400px;
  width: 400px;
  background: blue;
  touch-action: none;
}
					

结果

规范

规范 状态 注释
Compatibility Standard
The definition of 'touch-action' in that specification.
实时标准 添加 pinch-zoom property value.
Pointer Events – Level 3
The definition of 'touch-action' in that specification.
编者草案 添加 pan-left , pan-right , pan-up , pan-down property values.
指针事件 – 2 级
The definition of 'touch-action' in that specification.
推荐 Latest recommendation.
指针事件
The definition of 'touch-action' in that specification.
过时 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
touch-action Chrome 完整支持 36 Edge 完整支持 12 Firefox 完整支持 52 注意事项
完整支持 52 注意事项
注意事项 Not applicable to Firefox platforms that support neither pointer nor touch events.
完整支持 29 注意事项 Disabled
注意事项 Not applicable to Firefox platforms that support neither pointer nor touch events.
Disabled ). To change preferences in Firefox, visit about:config.
IE 完整支持 11
完整支持 11
完整支持 10 Prefixed
Prefixed Implemented with the vendor prefix: -ms-
Opera 完整支持 23 Safari 完整支持 13 WebView Android 完整支持 37 Chrome Android 完整支持 36 Firefox Android 完整支持 52
完整支持 52
完整支持 29 Disabled
Disabled ). To change preferences in Firefox, visit
Opera Android 完整支持 24 Safari iOS 完整支持 9.3 Samsung Internet Android 完整支持 3.0
pan-x and pan-y Chrome 完整支持 36 Edge 完整支持 12 Firefox 完整支持 52 注意事项
完整支持 52 注意事项
注意事项 Not applicable to Firefox platforms that support neither pointer nor touch events.
完整支持 29 注意事项 Disabled
注意事项 Not applicable to Firefox platforms that support neither pointer nor touch events.
Disabled ). To change preferences in Firefox, visit about:config.
IE 完整支持 11
完整支持 11
完整支持 10 Prefixed
Prefixed Implemented with the vendor prefix: -ms-
Opera 完整支持 23 Safari 完整支持 13 WebView Android 完整支持 37 Chrome Android 完整支持 36 Firefox Android 完整支持 52
完整支持 52
完整支持 29 Disabled
Disabled ). To change preferences in Firefox, visit
Opera Android 完整支持 24 Safari iOS 完整支持 13 Samsung Internet Android 完整支持 3.0
double-tap-zoom 非标 Chrome 不支持 No Edge 不支持 12 — 79 Firefox 不支持 No IE 完整支持 11
完整支持 11
完整支持 10 Prefixed
Prefixed Implemented with the vendor prefix: -ms-
Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No
manipulation Chrome 完整支持 36 Edge 完整支持 12 Firefox 完整支持 52 注意事项
完整支持 52 注意事项
注意事项 Not applicable to Firefox platforms that support neither pointer nor touch events.
完整支持 29 注意事项 Disabled
注意事项 Not applicable to Firefox platforms that support neither pointer nor touch events.
Disabled ). To change preferences in Firefox, visit about:config.
IE 完整支持 11
完整支持 11
完整支持 10 Prefixed
Prefixed Implemented with the vendor prefix: -ms-
Opera 完整支持 23 Safari 完整支持 13 WebView Android 完整支持 37 Chrome Android 完整支持 36 Firefox Android 完整支持 52
完整支持 52
完整支持 29 Disabled
Disabled ). To change preferences in Firefox, visit
Opera Android 完整支持 24 Safari iOS 完整支持 9.3 Samsung Internet Android 完整支持 3.0
none Chrome 完整支持 36 Edge 完整支持 12 Firefox 完整支持 52 注意事项
完整支持 52 注意事项
注意事项 Not applicable to Firefox platforms that support neither pointer nor touch events.
完整支持 29 注意事项 Disabled
注意事项 Not applicable to Firefox platforms that support neither pointer nor touch events.
Disabled ). To change preferences in Firefox, visit about:config.
IE 完整支持 11
完整支持 11
完整支持 10 Prefixed
Prefixed Implemented with the vendor prefix: -ms-
Opera 完整支持 23 Safari 完整支持 13 WebView Android 完整支持 37 Chrome Android 完整支持 36 Firefox Android 完整支持 52
完整支持 52
完整支持 29 Disabled
Disabled ). To change preferences in Firefox, visit
Opera Android 完整支持 24 Safari iOS 完整支持 13 Samsung Internet Android 完整支持 3.0
pinch-zoom Chrome 完整支持 56 Edge 完整支持 12 Firefox 不支持 No 注意事项
不支持 No 注意事项
注意事项 bug 1285685 .
IE 完整支持 11
完整支持 11
完整支持 10 Prefixed
Prefixed Implemented with the vendor prefix: -ms-
Opera 完整支持 43 Safari 完整支持 13 WebView Android 完整支持 56 Chrome Android 完整支持 56 Firefox Android 不支持 No 注意事项
不支持 No 注意事项
注意事项 bug 1285685 .
Opera Android 完整支持 43 Safari iOS 完整支持 13 Samsung Internet Android 完整支持 6.0
pan-up , pan-down , pan-left and pan-right Chrome 完整支持 55 Edge 完整支持 79 Firefox 不支持 No 注意事项
不支持 No 注意事项
注意事项 bug 1285685 .
IE 不支持 No Opera 完整支持 42 Safari 不支持 No WebView Android 完整支持 55 Chrome Android 完整支持 55 Firefox Android 不支持 No 注意事项
不支持 No 注意事项
注意事项 bug 1285685 .
Opera Android 完整支持 42 Safari iOS 不支持 No Samsung Internet Android 完整支持 6.0

图例

完整支持

完整支持

不支持

不支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

见实现注意事项。

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  • 最后修改:
  1. CSS
  2. CSS 参考
  3. 指针事件
  4. 特性
    1. pointer-events
    2. touch-action

Copyright  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1