Hi,
Newbie having problems… don’t all groan at once
I’m having problems with the “background-image: url(img/bg.jpg)” statement.
If the style sheet is in the root directory all is ok.
If the style sheet is embedded all is ok
The problem only occurs when using an external style sheet.
I’ve tried using the “./” if front of the path to both the image & the style sheet… I’ve also tried using the full path to these files.
All other styling within the document is working and both css & xhtml validate ok.
The problem line is in the #header
Hoping it’s something really dumb that I’ve done and just can’t see.
Here’s the embedded version on the doc:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test2 Backgound CSS Image</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
body {
background-color: #D3D3D3; /* lightgrey */
min-width: 900px;
min-height: 540px;
font: small arial, helveticta, verdana, sans-serif;
color: #FFD700; /* gold */
}
#page {
position: relative;
top: 0;
left: 0;
margin-top: 5px;
margin-left: auto;
margin-right: auto;
height: 535px;
width: 700px;
background-color: white;
}
#header {
height: 120px;
width: 700px;
background-color: #ADD8E6; /* lightblue */
background-image: url(img/bg.jpg);
background-repeat: repeat-x;
}
#content {
position: absolute;
top: 120px;
left: 0;
width: 100%;
height: 380px;
background-color: #F8F8FF; /* ghostwhite */
}
#footer {
position: absolute;
right: 0;
bottom: 0;
margin: 0;
height: 35px;
width: 100%;
background-color: #E6E6FA; /* lavender */
border-top: 1px solid;
}
p.copyright {
margin: 0 0 10px 10px;
padding: 5px 30px 0 0;
width: 300px;
float: left;
}
#footer ul.legal {
margin: 0;
padding: 5px 10px 0 0;
text-align: right;
}
#footer li {
display: inline;
}
#footer li a:link, #footer li a:visited {
color: #FFD700; /* gold */
}
</style>
</head>
<body>
<div id="page">
<div id="header">
<h1>Header</h1>
</div> <!-- header End -->
<div id="content"> <!-- start -->
<h2>Content</h2>
<p>Some text.</p>
</div> <!-- content End -->
<div id="footer">
<p class="copyright"> © copyright name 2011 all rights reserved</p>
<ul class="legal">
<li><a href="">about us</a> | </li>
<li><a href="">privacy policy</a> | </li>
<li><a href="">disclaimer</a> | </li>
<li><a href="">site map</a></li>
</ul> <!-- legal End -->
</div> <!-- footer End -->
</div> <!-- page End -->
</body>
</html>