2 replies [Last post]
anom
Offline
newbie
Last seen: 14 years 50 weeks ago
Joined: 2006-05-29
Posts: 6
Points: 0

I am having difficulties with the background image property, I believe.

I am trying to use it to display a background image (jpg) in one of my div containers.

If I were to use an external style sheet linked to my page the image does not appear on the webpage. I know that the style sheet is working because the other properties I have specified for fonts and colors, etc are working. This occurs in IE and Firefox.

If I embed the background image using an embedded style sheet on my webpage, the image is displayed.

I use the web developer tool bar available for Firefox to edit the css of my webpage. So when I use the "edit css" option from the tool bar to view the style sheet properties (when using an external style sheet) the image appears but as soon as I close the "edit css" option the image disappears.

Any suggestions would be greatly appreciated.

My CSS code:

body
{
margin: auto;
padding: 0;
background-color: black;
font-family: verdana, helvetica, arial, sans-serif;
color: #CC3300;
font-size: 10pt;
}

#header
{
width: 837px;
height: 170px;
}

At the moment I have put the background image in the embedded style sheet on the webpage.

The background image property command I am using is:

#header
{
background-image: url("images/css_images/headerimg.jpg");
background-repeat: no-repeat;
background-position: top left;
}

The webpage in question: http://www.students.signalflare.ca/ally/crashedpulse/temp01.html

Here is the same webpage with an external style sheet: http://www.students.signalflare.ca/ally/crashedpulse/temp02.html

Thanks

Ally

Tyssen
Tyssen's picture
Offline
Moderator
Brisbane
Last seen: 6 years 30 weeks ago
Brisbane
Timezone: GMT+10
Joined: 2004-05-01
Posts: 8201
Points: 1386

[solved] Need help with background image

It's because your CSS file is located in a different directory from the HTML file. The image path has to be relative to the CSS file, not the HTML file.

How to get help
Post a link. If you can't post a link, jsFiddle it.
My blog | My older articles | CSS Reference

anom
Offline
newbie
Last seen: 14 years 50 weeks ago
Joined: 2006-05-29
Posts: 6
Points: 0

[solved] Need help with background image

Thankyou.

Don't I feel stupid! :roll: