Forum Moderators: not2easy

Message Too Old, No Replies

Background image link in CSS

relative to css or html?

         

seashell

4:07 pm on Oct 13, 2003 (gmt 0)

10+ Year Member



I am using an image for the background in my css. My link to the image is relative. Is it supposed to be relative to the css file or html? The reason I ask is because in NN4 the background image doesn't display when I code it relative to the css file, but it does when it is coded relative to the html file. All other browser I test in (IE 5, Mozilla 1.4 and Netscape 7) display the background image correctly when it is coded relative to the css and not the html.

It would seem the only way around this is to have the css file in the same folder as the html in order for everything to work correctly in NN4. I don't want to have to do this, but I need the background image to display properly in NN4.

Any thoughts?

SuzyUK

4:22 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



relative to the css file..

there may be some other reason it's not displaying in NN4..
but I've forgotten all it's quirks..;)

try removing any quotes from around the image
try using the full path

Maybe someone else knows other NN4 background quirks..

Suzy

<added>..actually I think NN4 needs background properties as full properties so if you've got shorthand e.g. background: color image position.. etc try putting them into longhand form.. </added>

seashell

4:40 pm on Oct 13, 2003 (gmt 0)

10+ Year Member



I thought I just had a typo at first too, so I found another css document where the background did work in NN4. I copied and pasted the code and changed the image to reference the one I want. I checked all other browsers and it looks great. It still doesn't work in NN4.

Here's the css:

body {background-image: url(images/bgcolor.gif); background-repeat: repeat; }

I'm stumped...

Nick_W

4:42 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried it relative to the root dir?

/images/pic.gif

?

Nick

seashell

5:16 pm on Oct 13, 2003 (gmt 0)

10+ Year Member



Then it is no longer relative... correct?
Wouldn't that make it absolute?

Nick_W

5:17 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nope. root relative.

Relative to the root of your http docs..

I find it good proctice with imgs and links.

Nick

DrDoc

7:07 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Correct behavior: image path relative to CSS
NN4 only: image path relative to HTML

Nick's solution to use root-relative paths will solve the problem.