更新时间:2021-10-20 16:59:12
使用浏览器的网络检查器(F12),看看当浏览器请求bgbody.png形象,它使用的是什么绝对路径,为什么服务器返回一个404回应。
Use your browser's network inspector (F12) to see when the browser is requesting the bgbody.png image and what absolute path it's using and why the server is returning a 404 response.
...假设bgbody.png确实存在:)
...assuming that bgbody.png actually exists :)
是你的CSS样式表文件或在<风格>在一个页面
块?如果是在样式表则相对路径必须是相对于CSS样式表(而不是引用它的文档)。如果是在一个页面中,那么它必须是相对于当前的资源路径。如果你使用非基于文件系统的资源路径(即使用URL重写或URL路由),那么这会造成问题,这是***的总是使用绝对路径。
Is your CSS in a stylesheet file or in a <style>
block in a page? If it's in a stylesheet then the relative path must be relative to the CSS stylesheet (not the document that references it). If it's in a page then it must be relative to the current resource path. If you're using non-filesystem-based resource paths (i.e. using URL rewriting or URL routing) then this will cause problems and it's best to always use absolute paths.
去您的相对路径看起来是单独的样式表中存储图像。我不认为这是一个好主意 - 我支持存储图像和其他资源,如字体,在同一目录样式表本身,因为它简化了路径,也更符合逻辑文件系统的安排
Going by your relative path it looks like you store your images separately from your stylesheets. I don't think this is a good idea - I support storing images and other resources, like fonts, in the same directory as the stylesheet itself, as it simplifies paths and is also a more logical filesystem arrangement.