Welcome to WebmasterWorld Guest from 54.226.147.190

Forum Moderators: not2easy

Message Too Old, No Replies

Trouble With Background Images Not Showing

Will not show in external stylesheet?

     

annej

8:30 pm on Mar 30, 2003 (gmt 0)

WebmasterWorld Senior Member annej is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I've been active on webmaster world for a while but I'm new to CSS. So far I have studied the crash course information here as well as some other online information. I also bought Cascading Style Sheets 2.0 by Meyer.

I still can't figure out why this only works in the title section of my HTML page but not on a separate css sheet. The sheet and HTML page are in the same directory and it doesn't seem to matter if I give the full URL or not. I've about given up but hoped someone here could tell what I've doing wrong.

body {background-image:url(C:\02html\patches\bgpatt.jpg);}

in the head of an HTML page it works fine but if I put it on a CSS sheet it doesn't work at all. This is true no matter what version of Netscape or IE I've tried.

Meanwhile everything else I have on the separate stylesheet works fine. I haven't tried to replace tables but font size, font and background color etc works great.

I must be missing some subtle thing. Any ideas?

Anne

Nick_W

8:36 pm on Mar 30, 2003 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Sounds like a system thing rather than a CSS thing. Something to do with how Win handles paths with browsers or some such nonsense ;)

Try just (bgpatt.jpg); and see what happens. Otherwise try it on a server, it'll work fine...

Nick

annej

12:28 am on Mar 31, 2003 (gmt 0)

WebmasterWorld Senior Member annej is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Nick,

Thanks for the suggestion. I tried uploading both
body {background-image:url(bgpatt.jpg);}
and
body {background-image:url(http://www.mydomain.com/bgpatt.jpg);}
in my css page. It still doesn't work.

I don't have anything in the body tag in my HTML. It's just < body > . Should I have something else in there?

Anne

SethCall

5:29 am on Mar 31, 2003 (gmt 0)

10+ Year Member



your syntax seems absolutely fine. *once* i had to do
background-image:url(./gold-pattern1.jpg);

with the "./" to indicate current directory. Otherwise, I have no idea...

WibbleWobble

8:44 am on Mar 31, 2003 (gmt 0)

10+ Year Member



Are you calling the external sheet correctly? Are other properties in the external sheet being read, or is it all omitted?

BlobFisk

12:44 pm on Mar 31, 2003 (gmt 0)

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member



annej,

You say that the CSS and HTML files are in the same directory, but where is the image file? The URL call to the image in the CSS file is relative to the location of the CSS file.

Have you tried either putting the image in the same directory as the CSS file and using Nick's (bgpatt.jpg); suggestion, or using (patches/bgpatt.jpg); to go down a level into the patches folder where the image is?

HTH

annej

4:16 pm on Mar 31, 2003 (gmt 0)

WebmasterWorld Senior Member annej is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Thanks everyone for your suggestions. Once you helped me realize that everything was correct with my background image code I looked at my style sheet. When I copied it over to the style sheet from the HTML page I copied the < style > tags with it. Apparently I don't need them on the style sheet and once I got rid of them the background worked fine. I would have figured it out earlier but everything else was working so I focused on the background image.

Thanks again. I fill so silly that it was such a stupid mistake.

Anne

Nick_W

4:18 pm on Mar 31, 2003 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



>such a stupid mistake

Happens to me on a dailey basis. Glad it worked out ;)

Nick

 

Featured Threads

Hot Threads This Week

Hot Threads This Month