caljim36 — 2011-03-24T18:11:50-04:00 — #1
I am having trouble displaying a background image on a web page and have no clue what's wrong. I am sure it's something simple that I just don't see. Here is the code:
/*does not work*/
/*moved jpg to root directory. does not work*/
<p>This text displays in the header</p>;
The solidgreen.jpg file is a test file I created thinking there might be something wrong with the jpg file I am trying to display. Nothing works.
Thanks for any suggestions or help with this simple, perplexing problem.
ralphm — 2011-03-24T18:24:21-04:00 — #2
That's no use unless the css file is in the root folder too. Looks like a file path problem. Where is the css file in relation to the image? (That is, what's your file structure?) We could check for you if you post a link.
stevie_d — 2011-03-24T18:25:33-04:00 — #3
If the image is in the root directory then you can reference it with /solidgreen.jpg, no matter where your CSS and HTML files are in the structure.
caljim36 — 2011-03-24T18:33:45-04:00 — #4
I am developing the site on my computer and don't have a link you can see. The css folder and pictures folder are both in the root directory. What I have is:
I believe it is a path problem, also, but I can't see what it is.
caljim36 — 2011-03-24T18:43:15-04:00 — #5
I have a copy of the jpg in the root directory.
Is this correct notation:
It does not display.
caljim36 — 2011-03-24T19:38:34-04:00 — #6
A friend suggested I zip the directory on my computer and post it. You could see the whole website. It is not a large site at this point. Would that be helpful?
ralphm — 2011-03-24T20:29:17-04:00 — #7
What Stevie meant was this:
<font color='"Red"'>background-image: url(/solidgreen.jpg);</font>
ralphm — 2011-03-24T21:01:26-04:00 — #8
Actually, though, using
locally won't work, unless you are using a server environment like WAMP or MAMP.
The code that you posted initially should work if your folder structure is as you said.So yes, if you wish, zip the files and post them.
system — 2011-03-24T23:03:47-04:00 — #9
This is EXACTLY why my directory structure ALWAYS points down-tree... if you have to root or uptree (../) it over something simple like a image link, you probably have your file structure needlessly convoluted. Images for CSS should be in a subdirectory of wherever the CSS is -- since they are inherently (or should be) presentational that also makes reskinning easier as you can swap out CSS images and the CSS (theme) without effecting the content.
SERIOUSLY, if you have to start a URL in your CSS with "/" or "../" there is probably something horribly wrong with your directory structure.
caljim36 — 2011-03-25T19:12:18-04:00 — #10
I uploaded the zip file, but I don't see it. I will check back and upload it again if it does not appearl
caljim36 — 2011-03-31T14:26:02-04:00 — #11
I have finally solved the problem. As all of you have suggested, it was a syntax issue. Thanks to all who gave me suggestions. I tried them all until I hit paydirt.