CSS relative URL for images

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

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

In styles.css file, I will have something like this that works fine on localhost

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

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

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

Not sure how to get around this?

+5
source share
1 answer

With the directory tree that you provide, you do not need to change your path.

..means the parent directory of the CSS file, therefore a directory is implied assets/.

+7
source

All Articles