views:

250

answers:

3

Hi guys, I just installed xampp and I brought one of my live sites into it to be able to start working from localhost.

So to view my site, I navigate to localhost/example.com

I noticed some issues with images when on my html, I had for example:

<img src="/new_pictures/05.jpg" alt="Central Market"/>

Image wouldn't show up, but then I removed the / and this works:

<img src="new_pictures/05.jpg" alt="Central Market"/>

I seem to have a similar problem with the CSS background image, but I can't get it to work-if I remove the / there, the image doesn't show up on the live site. How do I make the background image show up on localhost?

Example CSS (works in live site but not localhost):

.outeremailcontainer {
height:60px;
width: 275px;
background-image:url(/images/feather_email2.jpg);
text-align:center;
float:right;
position:relative;
z-index:1;
}

Thanks!

+3  A: 

The image paths in your stylesheet should be where the image is relative to the stylesheet, for example if your .css file is in a directory like this on your site:

/css/styles.css

Your path should look like this (go up a directory, then into images)

background-image:url(../images/feather_email2.jpg);
Nick Craver
Indeed that did it. Thanks! It's strange to me that the path was working fine on the live site...
Joel
@Joel - I'm guessing that your site on localhost is something like `localhost/mySite/` as the root, and not just `localhost/`? That would be the reason :)
Nick Craver
ah. Cool-and yes indeed you are correct. :)
Joel
A: 

Try using ./ instead of / and make sure that you are specifying the correct path.

Sarfraz
+1  A: 

You can try the base tag - supported in most popular browsers - and then supply paths relative to the href attribute of the base tag. Or make sure you supply correct paths relative to the CSS stylesheet

dare2be