views:

147

answers:

4

I am using background images in my css, which, obviously, requires writing URLs in the css file.
So, while the relative path might be the same, the base URL will be different between development and production.
So, is there a better solution than:
1. changing it each time manually
2. using resources on the cloud with full URL
3. making the CSS files parsed as PHP, and using some
code in it (and then I have to fix the problem with caching).

A: 

I use the symfony framework, and I've found that parsing it as PHP works best. It's the most dynamic, and if you ever need anything more than just a URL, you can with the PHP.

James Skidmore
then you need to add some kind of client caching mechanizem to the css.
Itay Moav
+7  A: 

CSS URLs are parsed from the directory containing the CSS. Meaning it won't change. So all you should have to do is give them paths relative to the CSS Directory and you should be good.

CSS/main.css

div {
    background: transparent url(../images/background.jpg) no-repeat;
}
Ballsacian1
Now you made me fill stupid :-)
Itay Moav
A: 

One obvious answer to this is use the purest form of absolute URL, a filename, by putting all your CSS images into the CSS folder. That's used a lot. You gain simplicity in your URLs, you can now move or rename the CSS folder itself without hassle, and your stylesheet gets that little bit smaller.

AmbroseChapel
A: 

i asked that question b4 in another forum

http://www.nabble.com/Root-directory-(linking-CSS-JS-etc)-to23911119.html#a23923742

the solution was to use a view helper baseUrl

<img src="<?php echo $this->baseUrl();?>/images/foo.gif">
iceangel89
You missed my intention, I need to put URLs INSIDE the css file.
Itay Moav