Forum Moderators: open

Message Too Old, No Replies

Header background not working

css header background wont show

         

Str8TalkingBob

9:14 pm on Jan 3, 2010 (gmt 0)

10+ Year Member



Hi i am trying to have a header on my site with a logo image and then an image background that stretches accross the width of the page. The logo image shows up just fine but i cant for the life of me get the background image to work.

The whole css file is here


/*CONTENT START*/
div.content {
position: absolute;
margin: 145px 0px 0px 0px;
width: 100%;
z-index: 1;
}
/*CONTENT END*/

/*HEADER START*/
div.header {
position: absolute;
margin: 0px;
padding: 0px;
width: 287px;
height: 145px;
z-index: 2;
}
/*HEADER END*/

/*HEADERBG START*/
div.headerbackground {
background-image: url(images/matrixbg.jpg);
background-repeat: repeat;
margin: 0px;
height: 145px;
position: absolute;
width: 100%;
z-index: 1;
}
/*HEADERBG END*/

/*NAVIGATION START*/
div.navigation {
background-color: red;
border:1px solid green;
position: absolute;
margin: 145px 0px 0px 0px;
width: 199px;
z-index: 2;
}
/*NAVIGATION END*/
h1, h2, h3, p {
margin: 10px 35px 25px 205px;
}

img.logo {border:1px solid green;}

And the corresponding html file is here:


<head>
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
</head>
<body>
<div class="headerbackground">
<div class="content">
<p>
test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text test text
</p>
</div>
<div class="navigation">
<a href="www.google.com">GOOGLE</a></br>
<a href="www.google.com">GOOGLE</a></br>
<a href="www.google.com">GOOGLE</a></br>
</div>
<div class="headerbackground">
<div class="header">
<img class="logo" src="image/logo.png">
</div>
</div>

If i change:


/*HEADERBG START*/
div.headerbackground {
background-image: url(images/matrixbg.jpg);
background-repeat: repeat;
margin: 0px;
height: 145px;
position: absolute;
width: 100%;
z-index: 1;
}
/*HEADERBG END*/

To


/*HEADERBG START*/
div.headerbackground {
background-color: black;
background-repeat: repeat;
margin: 0px;
height: 145px;
position: absolute;
width: 100%;
z-index: 1;
}
/*HEADERBG END*/

It works fine with the color, just not with the image, the image path is correct and everything i've been wrestling with this for most of the day now, does anyone have any ideas what i am doing wrong?

lavazza

9:33 pm on Jan 3, 2010 (gmt 0)

10+ Year Member



Instead of
background-image: url(images/matrixbg.jpg);
try
background: url(images/matrixbg.jpg);

Str8TalkingBob

9:40 pm on Jan 3, 2010 (gmt 0)

10+ Year Member



No joy i'm afraid, really strange, it just seems like it should work, to me, had a pal of mine look at it too and he can't seem to figure out why it isn't working. I've tested in chrome, IE and firefox with the same result.

tedster

11:00 pm on Jan 3, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is the path to the image correct - and relative to the CSS file? You might try testing with an absolute address rather than a relative one.

Str8TalkingBob

12:47 am on Jan 4, 2010 (gmt 0)

10+ Year Member



Success, it works with the absolute address. Thanks a lot Tedster, you wouldn't beleive the hours i've spent ion this today. :) :) :)

lavazza

3:54 am on Jan 4, 2010 (gmt 0)

10+ Year Member



A quick and easy way to 'test' relative addressing:

Use the SciTE text editor

Highlight the path and file name and then (on a windoze pc) hit Ctrl + Shift + o

If the path is incorrect, nothing will happen

If the path is correct, the file will 'open' in a new tab - although, in the case of an image, the content will be meaningless (strings of chars that look like Wingdings on acid), it will confirm that your relative addressing works