相对链接 <img> 标签 src

Relative linking <img> tag src

我在 localhost/about/ 中有一个 HTML 页面,在 localhost/images. 中有一个图像 在我的 HTML 中,我有一个这样的 img 标签:

img src="../images/logo.png"

当我在浏览器中查看此页面时,徽标图像会显示一秒钟,然后出现 alt 文本。检查图像信息,src 中的页面更改为 "localhost/about/images/logo.png".

编辑:我是这样显示图片的。

 <!-- header-left start -->
 <!-- ================ -->
 <div class="header-left">
     <div class="logo">
         <a href="../"><img id="logo" src="../images/logo.png" alt="Alt Text" width="196" height="60"></a>
     </div>
 </div>
 <!-- header-left end -->

文件夹结构:

这个相对路径源是我做错了什么吗?

您可能需要检查 document javascript 对象的 baseURI 属性。 As defined by MDN:

The base URL is used to resolve relative URLs when the browser needs to obtain an absolute URL, for example when processing the HTML element's src attribute or XML xlink:href attribute.

通过在 Javascript 控制台中输入以下内容来检查基础 URL 值:

console.log(document.baseURI);