Click to See Complete Forum and Search --> : CSS background
milily
10-07-2003, 09:47 AM
Hi,
I want to use CSS to set the background. But I found it only works in IE. I hope it can also work in netscape and mozilla. The following is my code. Could any one tell me what's wrong with it? Thank you!
Helen
<style type = "CSS/text">
<!--
.banner {
background-image: url(./photo/bg0.gif);
}
-->
</style>
Your script type should be text/css, not CSS/text:
<script type="text/css">
Also, for the background-image, try it like this:
background-image: url("/photo/bg0.gif");
milily
10-07-2003, 03:49 PM
Thank you, Pyro,
I changed <script type="text/css"> and I tried the following ways and got the cooresponding results:
background-image: url("/photo/bg0.gif"); not work in IE or netscape.
background-image: url("photo/bg0.gif"); work in IE, but not in netscape
background-image: url("./photo/bg0.gif"); work in IE, not in netscape
So I still haven't found a way can work both in IE and netscape. My netscape version is very new.
Helen
spufi
10-07-2003, 04:01 PM
I don't believe you need to use quotes. Beyond that, make sure the path to the image is correct. Are you trying to go up one level and then look for the image in the photo folder, or is the photo folder within the current folder?
If you are going up one, I do it like this...
background-image:url(../photo/my.gif);
If you are going down one, I do it like this...
background-image:url(photo/my.gif);
milily
10-07-2003, 04:27 PM
Thanks, Spufi,
I already tried this, it works in IE. but not in Mozilla.
Helen
spufi
10-07-2003, 06:33 PM
Can you post a link to your site, or post all of your code? I know the code I posted works in Mozilla. I'm working on a revamp of my site that uses a good amount of the background image property, and I have no problems with it in Mozilla.
milily
10-08-2003, 12:57 PM
Thank you, spufi,
I uploaded it to internet. And then I found it is working in my own computer but it is not working in my office's computer. So it probably not the problem of code. It just doesn't work in some versions of netscape. And I also found it will not work if i use file-->open to open local file on the computer. Any way,
thank you so much for your help.
The url is http://www.clearshell.com/csstest/background.htm
Helen
DaveSW
10-08-2003, 01:20 PM
Using an external style sheet you shouldn't have html code tags - remove the
<style type="....">
and </style> and the comment tags.
spufi
10-08-2003, 01:20 PM
I was drawing blanks as to why it wasn't working when the light came on. You don't need the <style> tags in your CSS file. Below is the only thing you need. Comment code obviously being optional.
/* CSS Document */
.banner { background-image:url(photo/bg0.gif);
}
milily
10-09-2003, 09:46 AM
Thank you, spufi !!
Thank you, DaveSW!!