如何更改浏览器中的 `prefers-reduced-motion` 设置?

How do I change the `prefers-reduced-motion` setting in browsers?

在 CSS 中有大量关于如何使用 prefers-reduced-motion 媒体查询的文档。

这很好,但现在我在我的 CSS 中使用 prefers-reduced-motion,我希望能够测试启用此设置的人使用我的网站的感觉。不过,我找不到有关如何执行此操作的任何信息,而且我很难在浏览器设置中找到此设置。

也许这根本不是浏览器设置。也许这是在操作系统级别设置的。

这应该是一个 OS 设置,我在 Mac OS 中知道它位于:系统偏好设置 > 辅助功能 > 显示 > 减少运动。

在 Windows 10 中:设置 > 轻松访问 > 显示 > 在 Windows 中显示动画。

更多信息:

https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion

另请注意,并非所有浏览器都支持或遵守该设置

哦,我在 mdn 文档中没有看到“User Preferences”部分。 ‍♂️

For Firefox, the reduce request is honoured if:

  • In GTK/Gnome, if gtk-enable-animations is set to false. This is configurable via GNOME Tweaks (Appearance tab or General tab, depending on version).
    • Alternately, add gtk-enable-animations = false to the [Settings] block of the GTK 3 configuration file (~/.config/gtk-3.0/settings.ini).
  • In Windows 10: Settings > Ease of Access > Display > Show animations in Windows.
  • In Window 7 [& 8]: Control Panel > Ease of Access > Make the computer easier to see > Turn off all unnecessary animations (when possible).
  • In macOS: System Preferences > Accessibility > Display > Reduce motion.
  • In iOS: Settings > General > Accessibility > Reduce Motion.
  • In Android 9+: Settings > Accessibility > Remove animations.

Source: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion#User_Preferences

上面写着“for Firefox”,但是由于这是 OS 级别的系统设置,这可能是您更改支持此媒体查询的所有浏览器设置的方式。

根据其他答案,这是一个 OS 设置。

但是,为了测试,Chromium-based 浏览器允许您从开发者工具临时更改设置:

To simulate the operating system's reduced motion setting, without having to change your operating system setting:

  1. Press Ctrl+Shift+P on Windows/Linux or Command+Shift+P on macOS to open the Command Menu.

  2. Type reduced, to turn the simulation on and off. Select the Emulate CSS prefers-reduced-motion option, and then press Enter.

  3. Refresh the webpage and check whether your animations run.

来源:Microsoft Edge docs 关于“模拟减少的运动”(但不特定于 Edge)。