scroll‑start Property Playground - Online Carousel Initial Snap
Define the initial scroll position for a scroll container with scroll‑start. Test with and without snapping. New feature.
UD5 Toolkit
实时手势控制演示 · 触摸轨迹可视化 · 移动端体验最佳
touch-action: auto;
在移动设备上,切换不同的 touch-action 值后尝试在主画布上滑动,可以真实感受浏览器手势行为的变化。
none 会阻止页面滚动,pan-y 仅允许垂直滚动。桌面端请使用浏览器设备模拟模式获得完整体验。
touch-action 是一个CSS属性,用于控制浏览器在触摸设备上如何处理触摸手势(如平移、缩放)。它允许开发者指定在特定元素上哪些手势应由浏览器默认处理,哪些应完全交给JavaScript自定义处理。这对于构建流畅的移动端交互体验至关重要,特别是在需要自定义拖拽、绘图或滑动手势的应用中。
auto — 浏览器默认行为,允许所有手势(滚动、缩放等)。none — 完全阻止浏览器默认手势,所有触摸事件由JS处理。适用于自定义绘图画布、游戏等。pan-x — 仅允许水平单指平移,阻止垂直滚动和缩放。pan-y — 仅允许垂直单指平移,阻止水平滚动和缩放。pinch-zoom — 仅允许多指缩放(pinch zoom),阻止平移。manipulation — 允许平移和缩放,但阻止双击缩放(double-tap zoom),相当于 pan-x pan-y pinch-zoom 的组合。pan-left / pan-right / pan-up / pan-down — 仅允许指定方向的平移(浏览器支持有限)。touch-action 解决了这一痛点:
touch-action: none 防止画布上的触摸操作触发页面滚动。touch-action: none 确保拖拽流畅不被滚动打断。touch-action: pan-y 允许垂直滚动页面但水平滑动用于切换图片。touch-action: manipulation 允许平移和缩放但阻止双击放大。touch-action: none 获取完全的手势控制权。touchstart 和 touchmove 事件设置为passive模式(即 {passive: true}),意味着事件处理器无法调用 preventDefault() 来阻止滚动。设置 touch-action: none 告诉浏览器该元素不需要默认手势处理,从而使非passive的事件监听器能够正常工作。这是性能和交互之间的关键平衡机制。
touch-action 在所有现代浏览器中都有良好支持,包括Chrome 36+、Firefox 52+、Safari 13+、Edge 79+。iOS Safari从13版本开始支持,Android Chrome完全支持。pinch-zoom 值在Safari中支持较晚(Safari 13+)。pan-left/right/up/down 等方向性值的浏览器支持较为有限,建议使用 pan-x 和 pan-y 作为替代。对于不支持的旧浏览器,可配合polyfill或降级方案。
touch-action计算值。touch-action设置(该属性可继承)。{passive: false}选项以配合touch-action: none。touch-action: none 实际上可以提升性能。因为它明确告诉浏览器该元素不需要默认手势处理,浏览器可以跳过手势识别步骤,减少触摸事件的延迟(从约300ms降至接近即时)。这正是 manipulation 值的设计初衷之一——消除双击缩放带来的300ms延迟,同时保留平移和缩放能力。合理设置 touch-action 是移动端性能优化的最佳实践之一。
Define the initial scroll position for a scroll container with scroll‑start. Test with and without snapping. New feature.
Design a layout where nested grids share track sizes with their parent via subgrid. Copy the complete CSS.
Create a pure CSS scroll progress indicator using animation‑timeline: scroll(). No JavaScript. Copy the complete code.
Paste your CSS and see warnings for properties that have limited browser support. Links to CanIUse. Modernize safely.
Trigger different vibration patterns on mobile devices. Test if your phone supports haptic feedback. Simple demo.
Check current screen orientation and test the lock API. Useful for mobile web apps. Demo with code.
Create complex linear gradients with any number of color stops, exact angles, and length units. Live preview and CSS code.
Style underlines, overlines, and strike-throughs with colors, wavy styles, and thickness. Modern CSS text‑decoration.
Generate a random HTML/CSS card with different box model properties. Inspect and guess the size. For learners.
Design a button or card that glows on hover. Adjust shadow color, spread, and transition. Copy the CSS. Rich UI.
Create a realistic letterpress (debossed) text effect using CSS text‑shadow and background. Adjust depth and light direction. Copy code.
Experiment with CSS container queries. Resize a container and see the styles change according to its size, not the viewport. Learn the new spec.
Generate a subtle noise/grain texture as a CSS background pattern. Adjust opacity and size. For that film look.
Create a customizable checkerboard or grid background using pure CSS gradients. Adjust cell size and colors. Copy the code.
Upload two images and apply CSS blend modes (multiply, screen, overlay, etc.). See the result and copy the filter CSS. Pure frontend.
Add print styles like removing backgrounds, adding page breaks, setting margins. See print preview instantly.
Create a pure CSS countdown timer with a flipping number effect. Adjust duration and style. No JavaScript needed for display.
Create a glowing or rotating border animation around an element. Copy the CSS keyframes. Pure CSS magic.
Create a custom HTML/CSS progress bar with percentage, colors, and animation. Copy the code. Modern UI element.
Design a realistic neon sign text with multiple layers of glow. Copy the CSS and HTML. Perfect for headers.
A replica of the famous Flexbox Froggy game: solve alignment puzzles by writing CSS. Progress saved locally. Fun frontend learning.
Fetch a website's CSS and extract :root custom properties (‑‑color) to reveal its design token palette. For learning and inspiration.
Recreate the target CSS linear gradient by adjusting stops and colors. A unique game for front‑end developers to master gradients.
Browse and search all Font Awesome 6 icons with preview, class name, and unicode. Copy the HTML snippet. Perfect for web developers.
Create text with a gradient fill using CSS background-clip. Configure colors and direction. Copy the code. Works in modern browsers.
A complete, searchable list of all 140+ named HTML/CSS colors with their hex codes and color previews. Click to copy code. Essential web reference.
Preview any website inside emulated device viewports (iPhone, iPad, various resolutions). No screenshot, live interaction in an iframe. Local tool.
Visually experiment with Flexbox container and item properties. See the layout update in real time and copy the CSS. Learn by doing, fully interactive.
Minify JavaScript and CSS code to reduce file size for production. Remove whitespace and comments instantly. Run locally, your code stays private.
Easily create asymmetric border radius values and preview the result. Copy the generated CSS instantly. All interactively and browser-based.