Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Background Image Problem in External CSS

 
Mike Guthrie
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am coding a menu that utilizes javascript to change classnames on mouseover and mouseout events on the TD tag. Both Style classes that I use have an image defined for background. If I put the Style classes directly in my page between the Style tags the images appear correctly. If I put the style classes in an external CSS file and use the LINK tag to include it in my page, the images do not appear at all, although the other style properties work. Has anyone experienced this beahavior before and is there anything I can do to fix it??
Thanks,
Mike
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tyr using the full path name to the image and also a relative path to the image and see if either one works...

Eric
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like an issue with the URLs you're using. The question is, if you're using relative URLs in the CSS file, what are they relative to? Is it the location of the CSS file, or is it the location of the page that the link is on?

I believe it's the former, but my CSS has always worked in both places without error (I think!) and I've never really given it much thought. I use the following directory structure:

My background CSS looks like: { background: url(../images/image-1.gif); }

If your set-up is different to that then this might help you out.

Jules
 
Mike Guthrie
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
I solved the problem by placing a '../' before the image path. For example, I went from 'images/button.gif' to '../images/button.gif' and that worked.
- Mike
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic