You use relative paths in a .css file, they are relative to the location of the stylesheet, not the location of the current page:-
a.external
{
background-image:url('external-link.gif');
background-repeat:no-repeat;
}
will look for an image called 'external-link.gif' in the same directory as the .css file.
So if your directory structure looks like:-
- {Domain Root}
- Content
- Content\Style.css
- Images
- Images\MyImage.png
you could reference MyImage.png from Style.css with:-
url('../Images/MyImage.png')
Then if you moved your application into a subdirectory:-
- {Domain Root}
- Site
- Site\Content
- Site\Content\Style.css
- Site\Images
- Site\Images\MyImage.png
The same url ('../Images/MyImage.png') still finds the image because the relative path between the two resources has not changed.
See also: