【问题标题】:Why isn't my image displaying on my webpage?为什么我的图片没有显示在我的网页上?
【发布时间】:2014-10-25 03:22:39
【问题描述】:

您好,我是网络建设和 html 的初学者,想知道是否有人可以帮助我.. 我的图片不会显示在我的网页上。图片文件位于与 index.html 文件位于同一文件夹中的 images 目录中。

这是 index.html 文件中的部分代码

<body>
<h1> Minimalism  </h1>
<img src="../images/pd.jpg" alt="Partisal disinvestment">

</body>

但图像不会显示?路径对吗?我什至还在图像文件上设置了 chmod 755 之类的权限,但什么也没有。请帮忙谢谢

【问题讨论】:

    标签: html linux image web webpage


    【解决方案1】:
    <img src="images/pd.jpg" alt="Partisal disinvestment">
    

    ../ 表示向上一个目录,但您的images 文件夹与index.html 在同一目录中。所以你可以做src="./images/pd.jpg"(一个.代表当前目录)或者你可以离开它。

    【讨论】:

      【解决方案2】:

      请记住,../images/pd.jpg 将与提供 index.html 的路径相关。

      换句话说,如果index.html 是由/a/long/path/index.html 提供的,那么您对../images/pd.jpg 的引用意味着文件pd.jpg 必须存储在/a/long/images/pd.jpg 中,才能加载图像。

      【讨论】:

        【解决方案3】:

        检查文件名是否区分大小写。
        例如 pd.jpg 与 pd.JPG

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-02-25
          • 2013-02-07
          • 1970-01-01
          • 2021-06-01
          • 2023-02-12
          • 1970-01-01
          相关资源
          最近更新 更多