1. インタラクティビティ
  2. touch-action

インタラクティビティ

touch-action

タッチスクリーンでの要素のスクロールとズームの方法を制御するためのユーティリティ。

クラススタイル
touch-auto
touch-action: auto;
touch-none
touch-action: none;
touch-pan-x
touch-action: pan-x;
touch-pan-left
touch-action: pan-left;
touch-pan-right
touch-action: pan-right;
touch-pan-y
touch-action: pan-y;
touch-pan-up
touch-action: pan-up;
touch-pan-down
touch-action: pan-down;
touch-pinch-zoom
touch-action: pinch-zoom;
touch-manipulation
touch-action: manipulation;

基本的な例

touch-pan-ytouch-pinch-zoom などのユーティリティを使用して、タッチスクリーンでの要素のスクロール(パン)とズーム(ピンチ)の方法を制御します。

タッチスクリーンでこれらの画像をパンしてみてください

touch-auto

touch-none

touch-pan-x

touch-pan-y

<div class="h-48 w-full touch-auto overflow-auto ...">
<img class="h-auto w-[150%] max-w-none" src="..." />
</div>
<div class="h-48 w-full touch-none overflow-auto ...">
<img class="h-auto w-[150%] max-w-none" src="..." />
</div>
<div class="h-48 w-full touch-pan-x overflow-auto ...">
<img class="h-auto w-[150%] max-w-none" src="..." />
</div>
<div class="h-48 w-full touch-pan-y overflow-auto ...">
<img class="h-auto w-[150%] max-w-none" src="..." />
</div>

レスポンシブデザイン

プレフィックスa touch-action ユーティリティ md: のようなブレークポイントバリアントとともに、ユーティリティを適用するのはmedium 画面サイズ以上

<div class="touch-pan-x md:touch-auto ...">
<!-- ... -->
</div>

バリアントの使用方法の詳細については、バリアントのドキュメントをご覧ください。

Copyright © 2025 Tailwind Labs Inc.·商標ポリシー