首页 > 解决方案 > 我的 HTML 文件找不到任何其他文件并返回 404

问题描述

HTML 找不到位于同一根目录中的 .js、.png 或任何其他文件并返回 404。我已尝试在 html 中格式化链接以尽可能多地引用 css,但仍然没有结果。

HTML 代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <link href="style.css" rel="stylesheet" type="text/css"/>
  <meta charset="UTF-8" />
  <title>Simple website for ASCII Art Generator</title>
</head>
<body>
    <h1>ASCII Art Generator</h1>
<div>
  <form method="POST" action="/">     
    <center>
      <textarea type="text" name="input" rows="4" cols="80" placeholder="Write text here"></textarea> />
      <br>
      <label for="banner">Font:</label>
        <select id="banner" name="banner">
            <option value="standard">Standard</option>
            <option value="shadow">Shadow</option>
            <option value="thinkertoy">Thinkertoy</option>
        </select> 
        <input type="submit" value="submit" /></input>    
    </center>
  </form>
</div>
<div>
  <center>
    <textarea class="output" readonly="" wrap="off" rows="20" cols="110">{{.Text}}</textarea>
  </center>
</div>
<div>
  <a href="result.txt" download>
    <img src="images/download-button.jpg" alt="Download Button">
  </a>
</div>
</body>
</html>

目录:

-folder
   -server.go
   -form.html
   -style.css
   --images
       -download-button.jpg

在 Edge 开发工具中,它显示一个空白 style.css

标签: htmlcssdirectoryhttp-status-code-404

解决方案


尝试将“../”添加到 img src:

<img src="../images/download-button.jpg" alt="Download Button">


推荐阅读