XmisterIS
04-11-2012, 11:55 AM
Let's say I have a document at http://www.mydomain.com/mydocument.html, which links to the style sheet at http://www.mydomain.com/css/mystyles.css, via the relative path css/mystyles.css.
Let's say I have an image at http://www.mydomain.com/images/myimage.png. The document mystyles.css needs to set myimage.png as the background image of a div element, for the sake of argument.
I have discovered that the browser interprets relative paths within mystyles.css as being relative to mystyles.css. How can I instruct the browser to interpret relative paths in css files as being relative to the document in which they are included?
That would mean that instead of specifying url("../images/myimage.png") in mystyles.css, I would simply specify url("images/myimage.png").
This would be useful because it wouldn't matter where I put mystyles.css, the url would always point to images/myimage.png, relative to the document that links to mystyles.css.
Let's say I have an image at http://www.mydomain.com/images/myimage.png. The document mystyles.css needs to set myimage.png as the background image of a div element, for the sake of argument.
I have discovered that the browser interprets relative paths within mystyles.css as being relative to mystyles.css. How can I instruct the browser to interpret relative paths in css files as being relative to the document in which they are included?
That would mean that instead of specifying url("../images/myimage.png") in mystyles.css, I would simply specify url("images/myimage.png").
This would be useful because it wouldn't matter where I put mystyles.css, the url would always point to images/myimage.png, relative to the document that links to mystyles.css.