加载图像错误 [英] loading an image error

查看:115
本文介绍了加载图像错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题,我正在尝试加载一个灵巧的图像并出现以下错误:

i have a weird problem i am trying to load an spirte image and get the following error:

无法加载资源:服务器响应状态为404(未找到)"

"Failed to load resource: the server responded with a status of 404 (Not Found)"

我正在通过CSS加载它,

i am loading it like that through css:

background-image: url('/Img/icons.png');

当我通过aspx页面加载它时,位置很好,就像它加载得很好:

the location is fine cause when i load it through aspx page like that it loads fine:

<img src="Img/icons.png" />

位置为Img/icons.png对于CSS来说,它的Css/style.css

the location is Img/icons.png and for css its Css/style.css

在本地主机上

我无法弄清楚出什么问题了,将不胜感激谢谢.

and i cant figure up whats wrong any help will be appreciate Thanks.

推荐答案

如果您的CSS文件与Img文件夹位于同一文件夹中,请尝试

if your css file is in the same folder as your Img folder, try

background-image: url('Img/icons.png');

除此之外,您还必须向我们展示您的文件结构,以了解错误的位置.99.99%的用户只是使用错误的URL引用了图像.

apart from that, you will have to show us your file structure to understand where the error is. 99.99% you are simply referencing the image with the wrong url.

根据您指定的位置,它应该是

as per the location you've specified, it should be

background-image: url('../Img/icons.png');

此: .. 表示当前位置上方的一层,然后查找/Img/icons.png

this: .. means one level above the current location, then look for /Img/icons.png

这篇关于加载图像错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆