无法加载资源:服务器在服务器中响应404(未找到)的状态错误 [英] Failed to load resource: the server responded with a status of 404 (Not Found) error in server
问题描述
我尝试在我的图片文件夹中加载图片,但它不工作。
I'm trying to load up image in my Image Folder, but it's not working.
调试时,我看到此错误:
Upon debugging, I see this error:
Failed to load resource: the server responded with a status of 404 (Not Found)
我的图片编码是在.css文件中,
My image coding is in .css file that is,
background: url("../Images/bgbody.png") no-repeat;
我在这里做错了什么?
推荐答案
使用浏览器的网络检查器(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在样式表文件中, code>< style> 在页面中阻止?如果它在样式表中,那么相对路径必须是相对于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.
这篇关于无法加载资源:服务器在服务器中响应404(未找到)的状态错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!