Carousel (Auto-rotating Slides) new 走马灯(轮播图) web

标本可交互,可以直接操作。

Anatomy — every part, named解剖 —— 每个部件的名字

  1. 1 Viewport视口 overflow: hidden

    The frame that shows exactly one slide.

    刚好显示一张幻灯片的框。

    Prompt fragmentPrompt 片段

    the viewport: one slide visible, overflow hidden

    视口:一次显示一张,超出隐藏

  2. 2 Track轨道 transform

    All slides in a row, moved one width at a time.

    所有幻灯片排成一行,每次移动一张的宽度。

    Prompt fragmentPrompt 片段

    the track: slides in a row translated by 100% per step

    轨道:幻灯片横排,每步平移 100%

  3. 3 Arrows箭头 button

    Previous and next controls, shown on hover and focus.

    上一张/下一张按钮,悬停和聚焦时出现。

    Prompt fragmentPrompt 片段

    previous and next arrow buttons that appear on hover and focus

    悬停和聚焦时出现的上一张/下一张按钮

  4. 4 Position dots位置圆点 role=tablist

    One dot per slide; the active one fills as a countdown.

    每张一个圆点,当前的那颗随倒计时填满。

    Prompt fragmentPrompt 片段

    position dots where the active dot fills over the interval

    当前圆点在切换间隔内逐渐填满

Prompt — paste into your agentPrompt —— 直接粘贴给你的代理

Build an auto-rotating carousel: one slide visible at a time in a rounded viewport; advance every 3.2 seconds with a 550ms ease-out slide; show previous/next arrows on hover and focus, and position dots where the active dot fills as a countdown; pause auto-rotation on hover and keyboard focus; support Left/Right arrow keys; mark it up with aria-roledescription carousel/slide and hide inactive slides from assistive tech; under prefers-reduced-motion switch slides without sliding.

做一个自动轮播的走马灯:圆角视口一次显示一张,每 3.2 秒自动切换,用 550ms 缓出滑动;悬停和键盘聚焦时显示左右箭头,底部位置圆点中当前那颗随倒计时填满;悬停和键盘聚焦时暂停自动播放;支持左右方向键;用 aria-roledescription 标注 carousel/slide,非当前幻灯片对读屏隐藏;prefers-reduced-motion 时直接切换、不滑动。

Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时

Debug my carousel. Check that auto-rotation pauses on hover, focus and when the tab is hidden; manual navigation resets the timer instead of stacking timers; the countdown dot restarts on every change; the track wraps cleanly at both ends; inactive slides are aria-hidden and their links not focusable; arrows are reachable by keyboard; and reduced motion removes the sliding transition. The symptom:

调试我的走马灯。检查:悬停、聚焦和页面隐藏时自动播放是否暂停;手动切换是否重新计时,而不是叠加多个计时器;每次切换时倒计时圆点是否重新开始;首尾是否能平滑循环;非当前幻灯片是否 aria-hidden、里面的链接不能被聚焦;箭头能否用键盘操作;以及减少动态效果时是否去掉滑动。症状是:

In code代码里叫什么

Framework框架Symbol符号Note说明
ARIA aria-roledescription="carousel" / "slide" announce the region and each slide播报区域和每张幻灯片
CSS transform: translateX(-100% × index) slide the track one viewport at a time每次把轨道平移一个视口宽度
JS setTimeout / setInterval advance on a fixed interval and reset after manual navigation按固定间隔切换,手动切换后重新计时
Swiper Swiper autoplay the common library route, with loop, pagination and navigation常用的库做法,支持循环、分页圆点和箭头

See also相关词条

我的参考集

组合知名网站、UI 元素、视觉风格和平面设计案例,导出给 AI。

你的下一份设计,从这里开始。

在任意案例旁点击「加入参考」,就能把品牌、组件、风格和平面设计案例组合成一份 AI 设计说明。

搜索参考库Search the library

输入关键词,搜索所有参考。