By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,676 Members | 1,759 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,676 IT Pros & Developers. It's quick & easy.

How can a css in a folder read a pics in another folder

P: n/a
I have css in a folder name css. so how can this .css file read a pics file
from another folder eg, pics/a.jpg.

Both css folder and pics folder are located in a folder named project.

I know i can call the pic by url(project/pic/a.jpg)

However, its very inconveninet when I change the folder name eg from project
to project10.

so, are there any other way to do this?

Please advice. Thanks!

Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
/Jorntk/:
I have css in a folder name css. so how can this .css file read a pics file
from another folder eg, pics/a.jpg.

Both css folder and pics folder are located in a folder named project.

I know i can call the pic by url(project/pic/a.jpg)
If the above statement is placed in a "project/css/the.css" file
(for example) the URI for the "a.jpg" would resolve to
"project/css/project/pic/a.jpg". You should use 'url(../pic/a.jpg)'
if you have:

project/
css/the.css
pic/a.jpg

<http://www.w3.org/TR/CSS21/syndata.html#uri>:
For CSS style sheets, the base URI is that of the style sheet, not
that of the source document.


--
Stanimir
Jul 20 '05 #2

P: n/a
Jorntk wrote:
I have css in a folder name css. so how can this .css file read a
pics file from another folder eg, pics/a.jpg.

Both css folder and pics folder are located in a folder named
project.

I know i can call the pic by url(project/pic/a.jpg)
ITYM, url("/project/pic/a.jpg")
However, its very inconveninet when I change the folder name eg from
project to project10.
In order:

(a) don't change sub directory ("folder") names
(b) use server redirects
so, are there any other way to do this?


(c) put the image in the same directory ("folder") as css file

--
Brian (remove "invalid" from my address to email me)
http://www.tsmchughs.com/
Jul 20 '05 #3

P: n/a
Jorntk wrote:
I have css in a folder name css. so how can this .css file read a
pics file from another folder eg, pics/a.jpg.

Both css folder and pics folder are located in a folder named
project.

I know i can call the pic by url(project/pic/a.jpg)

However, its very inconveninet when I change the folder name eg from
project to project10.

so, are there any other way to do this?


I somehow missed the obvious. Given subdirectory for css

/project/

and subdirectory for images

/project/pic/

use a relative url.

body {
background-image: url("pic/a.jpg");
}

This means, look for "a.jpg" in the subdirectory of whatever directory
has the css file.

(It's still better not to rename things; there are often things you
forget somewhere else in the site that will no longer find files because
of name changes.)

--
Brian (remove "invalid" from my address to email me)
http://www.tsmchughs.com/
Jul 20 '05 #4

P: n/a
Tim
On Sat, 1 May 2004 19:28:13 -0700,
"Jorntk" <jo****@yahoo.com> posted:
I have css in a folder name css. so how can this .css file read a pics file
from another folder eg, pics/a.jpg.

Both css folder and pics folder are located in a folder named project.

I know i can call the pic by url(project/pic/a.jpg)

However, its very inconveninet when I change the folder name eg from project
to project10.


Two ways:

1. Use relative links. Back out of a folder using ../ into the parent, the
append the new name onto the end of it.

e.g. Given some files located at:

/an/example/here.test
/an/other/example.test

The first one (here.test) could refer to the second (example.test)
with a link like "../other/example.test".

2. Use absolute links. All links include the full path to the destination,
starting with a slash / to indicate the root.

e.g. Given those same files as before, they'd each have links using the
full path to the other. The first would refer to the second with a link
like "/an/other/example.test".

Depending on what you mean by changing a folder name, you're in for a hard
time. If you rename things, you've got to make quite a lot of changes on
anything else that referred to it.

--
If you insist on e-mailing me, use the reply-to address (it's real but
temporary). But please reply to the group, like you're supposed to.

This message was sent without a virus, please delete some files yourself.
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.