Page 1 of 1

Problem with locating url of an image in css

PostPosted: 24. March 2010 22:48
by shnjavi
Hello, I'm kind of a newbie on here, and I will ask a question as simple as I can, so.. I reinstalled xampp 1.7.2. and my root folder is now "htdocs". The problem is:
In my css file I have to locate a background image. When I had located it (with the previous installation) I used the code:

Code: Select all
background: url('images/polaroid.jpg');


but now I have to write this, in order to work properly:

Code: Select all
background: url('http://localhost//images/polaroid.jpg');


Can someone please help? What seems to be the problem? I would be really grateful! Thanks. And sorry about my English :oops:

One question more.. How can I change my root folder, e.g. if I want it to be beneath "htdocs" folder , e.g. "htdocs/newfolder" (how to make "newfolder" my default?)

Re: Problem with locating url of an image in css

PostPosted: 24. March 2010 23:01
by MisterK
perhaps you need to change the reference to an absolute one -
rather than:
Code: Select all
url('images/polaroid.jpg');

try:
Code: Select all
url('/images/polaroid.jpg');


Seems like either the page you are viewing, or the css file you are referencing isn't in the root area. I can't remember which matters off the top of my head (maybe both)

Re: Problem with locating url of an image in css

PostPosted: 24. March 2010 23:03
by MisterK
To your second question, your root folder is listed in httpd.conf.

Re: Problem with locating url of an image in css

PostPosted: 25. March 2010 18:50
by shnjavi
Thank you for answering.
Yes, I've found it, somewhere in line 225 or so, in httpd.conf, and all my links on html page are successfully connected.

But still, in my css file, background images can't work properly if I don't use this path:

Code: Select all
background: url('http://localhost//images/polaroid.jpg') no-repeat;



Why do I have to write http://localhost? I don't understand :(