CSS background

liunx

Guest
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");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.

HelenI 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);Thanks, Spufi,

I already tried this, it works in IE. but not in Mozilla.

HelenCan 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.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 <!-- m --><a class="postlink" href="http://www.clearshell.com/csstest/background.htm">http://www.clearshell.com/csstest/background.htm</a><!-- m -->

HelenUsing an external style sheet you shouldn't have html code tags - remove the
<style type="....">
and </style> and the comment tags.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);
}Thank you, spufi !!
Thank you, DaveSW!!
 
Back
Top