homepage Welcome to WebmasterWorld Guest from 54.166.108.167
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

    
Trouble With Background Images Not Showing
Will not show in external stylesheet?
annej




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

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




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

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




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

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




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

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




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

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

BlobFisk




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

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




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

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




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

>such a stupid mistake

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

Nick

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved