【问题标题】:How to add image in to HTML from different folder [duplicate]如何将图像从不同的文件夹添加到 HTML [重复]
【发布时间】:2021-09-20 19:38:16
【问题描述】:

我想将突出显示的图像添加到我的 HTML 文件中。但我的 HTML 文件位于不同的文件夹中。我正在使用 VS:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="stylesheet.css">
</head>
<body>
    <!-- image add here -->
    <img src="    " alt="">
    
</body>
</html>

【问题讨论】:

    标签: html css image


    【解决方案1】:

    先生,您可以将图像从文件夹拖动到 chrome 选项卡。 现在在搜索栏中,您将看到该图像的链接在

    中使用它
    <img src=" paste the link here   " alt="">
    

    https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/Dealing_with_files

    ** 我认为这个网址对你有用**

    <img src="../images/image-victor.jpg" alt="">
    

    【讨论】:

      【解决方案2】:

      使用 ./ 或 ../ 然后你会看到你的文件夹列表

      【讨论】:

      【解决方案3】:

      使用./ 引用当前目录。使用../ 从父目录引用。

      在您的示例中,您应该使用../ 所以,它是src="../images/image-victor.jpg"

      【讨论】:

        【解决方案4】:

        先生,您可以使用

        &lt;img src="/images/image-victor.jpg" alt="image"&gt;

        它会带你到“My”的基础父目录,即final,然后转到“images”并进一步选择“image-victor.jpg”

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-05-02
          • 2014-07-04
          • 1970-01-01
          • 2015-08-30
          • 2012-11-15
          • 2013-01-05
          相关资源
          最近更新 更多