Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS relative url to images

Tags:

css

path

I am developing on my localhost - http://localhost/mysite, and within that I have the following directory structure:

-assets
--css
---styles.css
--images
---background.png

Within the styles.css file, I would have something the following, which works fine on localhost

background-image: url(../images/background.png);

However, the live server works off a subdomain - http://test.liveserver.com. This means that the css rule has to change as follows:

background-image: url(/assets/images/loginlogo.png); 

Not sure on the best way to get around this?

like image 819
JonoB Avatar asked Feb 21 '12 20:02

JonoB


1 Answers

With the directory tree you are providing you don't have to change your path.

.. means the parent directory of the CSS file so the assets/ directory is implied.

like image 105
Spyros Mandekis Avatar answered Sep 20 '22 05:09

Spyros Mandekis