E.Meir
E.Meir

Reputation: 2216

loading an image error

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

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

i am loading it like that through css:

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

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

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

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

its on local host

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

Upvotes: 0

Views: 1680

Answers (5)

Manoj Dwivedi
Manoj Dwivedi

Reputation: 95

Could you also provide the folder structure of the CSS file and the .aspx page ?, that would help us narrow down the issue. From here it seems your css file has navigational issue while accessing the image whereas the aspx doesn't seem to have it because of correct hierarchical path.

Upvotes: 0

Luca
Luca

Reputation: 9725

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

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

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.

EDIT:

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

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

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

Upvotes: 3

codingbiz
codingbiz

Reputation: 26386

Depends on the relative path to your current page

Try

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

or

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

or

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

Upvotes: 0

IrishChieftain
IrishChieftain

Reputation: 15253

See if this works:

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

Upvotes: 0

Jason
Jason

Reputation: 2364

The obvious difference here is the first slash. Looks like your css should be:

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

Or alternatively

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

Upvotes: 1

Related Questions