Skip to content

Broken 镜像

快速摘要

你的 `<img>` 标签点 到 file 那个 doesn't exist, 是 in 错误位置, or 失败到 加载 — 浏览器 shows broken 镜像 icon.

为什么发生

  • 错误 file path in src attribute

  • 镜像 file 是删除, moved, or renamed

  • 情况-sensitive filename mismatch on 情况-sensitive 服务器 (Linux)

最小示例

✗ 错误代码
<img src="/images/hero.png">
✓ 修复代码
<img src="/images/hero.jpg" alt="Hero image">

file 是 hero.jpg, 不 hero.png — src path 必须 match 实际 filename. 总是包含 alt 文本 for accessibility.

如何诊断

  • 打开镜像 URL directly in 浏览器 — 做它 加载?

  • 检查 Network tab in DevTools for 404 状态 on 镜像

  • 验证 file exists at path specified in src

如何修复

  • 正确 src path 到 match 实际 file 位置

  • Use 绝对 URLs (https://...) for 外部镜像

  • Match filename 精确地, 包含情况 on 情况-sensitive 服务器

如何预防

  • Use 构建 tools (Vite, Webpack) 那个验证 asset paths at 构建时间

  • Keep 镜像 in dedicated folder 使用 consistent naming

相关资源

相关术语

相关课程

  • HTML

    学习 HTML 基本

相关练习

相关工具

  • URL Parser

    Parse 镜像 URLs 到查找 path issues.

← 返回语言