Reference Reference reference

CSS media query

media query 根据视口、设备或偏好应用样式。

语法

text
@media (min-width: 768px) { ... }

最小示例

js
matchMedia('(min-width: 768px)').matches;

常见错误

  • 只看语法不看运行环境限制。
  • 没有处理错误、权限或兼容性分支。
  • 示例上线前应结合真实浏览器、服务器或 Git 仓库验证。

相关内容