【问题标题】:Why is html not loading my images? [closed]为什么 html 不加载我的图像? [关闭]
【发布时间】:2016-10-24 12:16:59
【问题描述】:

为什么我的图片无法加载?

<div id="cf">
  <img class="bottom" src="/img/home.jpg" />
  <img class="top" src="/img/home2.jpg" />
</div>

【问题讨论】:

  • 路径错误或者你的css类隐藏了它们
  • 您确定要在路径的开头使用/吗?也许你想要一个相对路径而不是绝对路径。
  • @bert tappel 我怀疑您在 html 中使用了 标记,这会导致您的链接受到错误
  • 请给我们看minimal reproducible example这是一个img目录、img/..目录等的截图。

标签: css html image load


【解决方案1】:

您确定图片在正确的位置吗? 如果您使用的是 linux 网络服务器,请检查文件名是否相等(检查大小写) - 在 windows 中 Home.jpg 和 home.jpg 相等,在 linux 中不相等。

也许图像文件位于同一目录而不是根目录?对同一目录中的文件使用 ./home.jpg。

【讨论】:

  • 路径100%正确,图片不在根目录,全部小写。
  • ./img/home.jpg 是正确的路径...括号表示没有 .这是正确的,但不是,谢谢!
  • 您可以直接通过网络浏览器打开图片吗?不去你的 html 文件,而是去 example.com/img/home.jpg?
【解决方案2】:
   **Please check the image path**
 <div id="cf">
      <img class="bottom" src="https://www.google.co.in/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" />
      <img class="top" src="https://www.google.co.in/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" />
    </div>

【讨论】:

  • /Users/robbin/Desktop/Scr​​een Shot 2016-10-24 at 14.17.26.png
  • 请看链接,在括号中,它显示了图像,所以路径是正确的。 postimg.org/image/x28tyf8sj
  • 您能否粘贴完整的代码以便我检查,或者您可以提供任何在线路径仅用于检查,以便您确定这只是错误的路径。
猜你喜欢
  • 2021-07-30
  • 1970-01-01
  • 2023-03-05
  • 2021-12-08
  • 1970-01-01
  • 2016-12-20
  • 1970-01-01
  • 2015-06-02
  • 2022-01-11
相关资源
最近更新 更多