Forum Moderators: not2easy

Message Too Old, No Replies

Relative paths for background images

         

Kysmiley

3:42 am on Jan 2, 2005 (gmt 0)

10+ Year Member



Im having a difficult time to set the background images with relative paths. For some reason i have not figured out, on some CSS i can use relative and others will not accept it even though everything is the same in both the locations of the images and the css files are the same the only difference is the name of the css files. I also have a test server on my laptop and I am not able to use a relative path with it yet all the other images I can. Heck on the test bed i have to set the path pointing to my on-line server so the background images will show up. Funny part is im in a truck moving down the road not even connected to the net yet the relative path wont work
Any ideas on why
Pat

createErrorMsg

3:50 am on Jan 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you setting the paths relative to the CSS file or the HTML (or PHP or ASP) file?

mcibor

10:19 pm on Jan 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



And what is the right relation? I would think, that it should be set relative to the css, otherwise it would be a bit stupid (you can have many pages using one css).

createErrorMsg

3:49 am on Jan 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



And what is the right relation?

Relative to the CSS file is right in most cases. If, like me, you have a hard time keeping relative paths straight, you can use a root-relative path instead...

background: url(../images/image_name.gif)

This ought to refer to the same folder from anywhere on the site and can be helpful, especially if you're in the habit of using subfolders to store included files.

cEM

rocknbil

4:06 pm on Jan 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



?
That goes up one directory from where you are, doesn't it?

background: url(/images/image_name.gif);

works from the domain root down from wherever you are.

TheDoctor

5:27 pm on Jan 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Relative to the CSS file is right in most cases.

Not for Netscape 4. Netscape 4 uses a URL relative to the HTML file.

But I think everything that can recognse an @import uses a URL relative to the CSS file. At least I hope so, or else I've been doing it wrong all this time! :)

Which browser are you using, Kysmiley?