PDA

View Full Version : Super simple question - but stuck - HTML


spadez
02-09-2008, 02:19 PM
Hey guys.

My structure goes like this:

website.com/css/style.css
website.com/images/
website.com/index.html

I have the written the locations of some images in my CSS file. I dont want to hardcode my images because im changing my url soon, so is there a way to specify the root of the website in the url.

For example, at the moment in my css i have this as the location of the image:

"/images/image1.jpg"

But, that points to www.website.com/css/images/image.jpg

I need it to point to www.website.com/images/images.jpg

So i what i need is something like this:

"<root of site>/images/image1.jpg" but make it flexible, so if i upload the file to any url it will work, i.e not put website.com in the image address.

Please help!

oesxyl
02-09-2008, 02:24 PM
use relative path to the file, for example in index.html use images/image1.jpg instead of /images/image1.jpg, that's all, :)

best regards

spadez
02-09-2008, 02:29 PM
Hey

The code in my css is

background-image:url(images/footer.jpg)

The location of my image is www.website.com/images/footer.jpg
The location of my css is www.website.com/css
The location of my image folder is www.website.com/images

Why isnt that working then?

spadez
02-09-2008, 02:35 PM
Fixed, thank you for the help.

oesxyl
02-09-2008, 02:40 PM
Hey

The code in my css is



The location of my image is www.website.com/images/footer.jpg
The location of my css is www.website.com/css
The location of my image folder is www.website.com/images

Why isnt that working then?
because www.website.com is your domain
your files ar in / on your domain and you must use the file system path

this don't work:

background-image:url(images/footer.jpg)


because this is in css/style.css and the relative path to / from style.css is ../
that means you must have:

background-image:url(../images/footer.jpg)


best regards