Forum Moderators: not2easy

Message Too Old, No Replies

Firefox don't show my background image

Problem with css and Firefox

         

cssNewbee

9:25 pm on Nov 19, 2007 (gmt 0)

10+ Year Member



This is the code in my stylesheet:

.color{
background: url(red.jpg);
}

And this is the html-page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta name=" " content=" ">
<link rel="stylesheet" type="text/css" href="styles.css">
<title>My Title</title>
</head>

<body>

Color

</body>

</html>

I want to use an image instead of a color because then I can have the precise color behind another image. This works perfect in Safari but Firefox doesn't seem to recognize the image at all. I've tried to extend the code with more details, but it doesn't work:

.color{
background-image: url(red.jpg);
background-repeat: repeat;
etc..etc...(this is just a sample)
}

Can someone help me?

[edited by: SuzyUK at 9:37 pm (utc) on Nov. 19, 2007]
[edit reason] examplifying some personal details [/edit]

sonjay

9:54 pm on Nov 19, 2007 (gmt 0)

10+ Year Member



You specified your color using .color. Yet you don't specify anything on your page with class="color."

Perhaps try <body class="color">?

cssNewbee

10:52 pm on Nov 19, 2007 (gmt 0)

10+ Year Member



Yes I know that it should be

<body class="color">

I just forgot to write it in the sample code, thanks for noticing.

SuzyUK

11:58 pm on Nov 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi cssNewbee and Welcome to WebmasterWorld!

.. try adding the color class to your HTML opening tag too
e.g.

<html class="color">

or rather than classes try something like the following in your CSS file..

html, body {background: url(red.jpg);}

presuming there is no other background declarations on these elements if there is it will need a bit more

somewhere in the distant memories I think the XHTML canvas background should be on the HTML element, rather than the body however that could be completely wrong :o

-Suzy

[edited by: SuzyUK at 11:59 pm (utc) on Nov. 19, 2007]

cssNewbee

12:22 am on Nov 20, 2007 (gmt 0)

10+ Year Member



Thanks for the reply.

I finally found out that the image file was damaged or truncated, som I just "saved for web" in Photoshop, and then it worked fine!

Silly problems often has silly solutions.

Thanks for trying to help anyway

SuzyUK

12:56 am on Nov 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No Problem, thanks for letting us know :)