Extra space on right side of background image

Hi,
I am learning how to make an online address book. I had a background image but when i view it online, there is some extra space on the right as you can see in the attached screenshot. I am giving my code below.

 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>3 col layout with equalising columns and footer</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css"> 
* {margin:0;padding:0}
h1,h2,h3,ul,p {margin:0 0 .5em 0;padding:5px;}
html,body {
 height:100%;
 text-align:center;
}
#outer{
 min-height:100%;
 width:760px;
 background:#000 url(header-copy.jpg) repeat-y;
 border-left:1px solid #000;
 border-right:1px solid #000;
 color: #000;
 text-align:center;
 margin:-22px auto 0;
}
* html #outer{height:100%;} /*for IE as it treats height as min-height anyway*/
#header{
 width:760px;
 background:#304a00 url(header-copy.jpg) repeat-y;
 border-bottom:1px solid #000;
 border-top:22px solid #000;
 color: #000;
text-align:center;
}
#header ul{ list-style:none;}
#header ul li{display:inline;}
#header  a{color:#fff}
#header2{
 width:760px;
 background:#304a00 url(header-copy.jpg) repeat-y;
 border-top:1px solid #000;
 border-bottom:1px solid #000;
 color: #000;
text-align:center;
}
#centrecontent { width:760px;}
#right {
 float:right;
 width:379px;
}
#left {
 width:379px;
 float:left;
}
 
#footer {
 width:760px;
 clear:both;
 margin:auto;
 height:20px;
 border:1px solid #000;
 background: #4c7300;
 color: #fff;
 text-align:center;
}
* html #footer {/*only ie gets this style*/
 height:22px;/* for ie5 */
 he\\ight:20px;/* for ie6 */
}
.clearer{clear:both;height:1px;overflow:hidden;margin-top:-1px;}
</style>
</head>
<body>
<div id="outer">
 <div id="header">
  <h1><align="center">Address book online</c>
 </h1>
<h2><align="center">Your contacts on line 24 hours a day anywhere in the world</h2>
 
 </div>
 <div id="header2">
  <h2>Important Tip</h2>
  <p>Always have a backup of your online/cellphone addresses in a cd or a flashdrive</p>
 </div>
 <div id="centrecontent">
  <html> 
 <head> 
  <title>Address Book</title>  </head> 
 <body>
<?php 
//*MY PHP CODE HERE.
?>
</body> </html> 
 
 </div>
 <div class="clearer"></div>
</div>
<div id="footer">Created by jppp.  All rights reserved.</div>
</body>
</html>

My image is 760px wide and 150 px high.

Do you have this online where we can see what’s going on with actual code and images? Linky?

cheers,

gary

I am giving my full code below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>3 col layout with equalising columns and footer</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css"> 
* {margin:0;padding:0}
h1,h2,h3,ul,p {margin:0 0 .5em 0;padding:5px;}
html,body {
 height:100%;
 text-align:center;
}
#outer{
 min-height:100%;
 width:760px;
 background:#000 url(header-copy.jpg) repeat-y;
 border-left:1px solid #000;
 border-right:1px solid #000;
 color: #000;
 text-align:center;
 margin:-22px auto 0;
}
* html #outer{height:100%;} /*for IE as it treats height as min-height anyway*/
#header{
 width:760px;
 background:#304a00 url(header-copy.jpg) repeat-y;
 border-bottom:1px solid #000;
 border-top:22px solid #000;
 color: #000;
text-align:center;
}
#header ul{ list-style:none;}
#header ul li{display:inline;}
#header  a{color:#fff}
#header2{
 width:760px;
 background:#304a00 url(header-copy.jpg) repeat-y;
 border-top:1px solid #000;
 border-bottom:1px solid #000;
 color: #000;
text-align:center;
}
#centrecontent { width:760px;}
#right {
 float:right;
 width:379px;
}
#left {
 width:379px;
 float:left;
}
 
#footer {
 width:760px;
 clear:both;
 margin:auto;
 height:20px;
 border:1px solid #000;
 background: #4c7300;
 color: #fff;
 text-align:center;
}
* html #footer {/*only ie gets this style*/
 height:22px;/* for ie5 */
 he\\ight:20px;/* for ie6 */
}
.clearer{clear:both;height:1px;overflow:hidden;margin-top:-1px;}
</style>
</head>
<body>
<div id="outer">
 <div id="header">
  <h1><align="center">Address book online</c>
 </h1>
<h2><align="center">Your contacts on line 24 hours a day anywhere in the world</h2>
  <ul>
   <li><a href="spointfooterleft.htm"></a> </li>
   <li><a href="spointfooterright.htm"> </a> </li>
   <li><a href="spointfooter.htm"></a> </li>
                        <li><a href="xyz.html"></a></li>
 
  </ul>
 
 </div>
 <div id="header2">
  <h2>Important Tip</h2>
  <p>Always have a backup of your online/cellphone addresses in a cd or a flashdrive</p>
 </div>
 <div id="centrecontent">
  <html> 
 <head> 
  <title>Address Book</title>  </head> 
 <body>

 
<?php 
// Connects to your Database
$mysql_link = mysql_connect('localhost', 'jppp_pvarier', '/*MniVVVmP*/') ;
mysql_select_db('jppp_addresses') or die('Could not select database'); 
 
 
if ( $mode=="add") 
{
 Print '<h2>Add Contact</h2>
 <p> <form action=""; echo($PHP_SELF); method="post">
 <table> 
<tr>
<td>Name:</td>
<td><input type="text" name="name" /></td>
</tr>
 <tr>
<td>Phone:</td><td><input type="text" name="phone" /></td>
</tr> 
<tr>
<td>Email:</td><td><input type="text" name="email" /></td>
</tr>
 <tr>
<td colspan="2" align="center"><input type="submit" /></td>
</tr>
 <input type=hidden name=mode value=added>
 </table>
 </form>
 <p>'; 
} 
if ( $mode=="added") 
{ mysql_query ("INSERT INTO address (name, phone, email) 
VALUES ('$name', '$phone', '$email')");
 } 
if ( $mode=="edit") { Print '<h2>Edit Contact</h2> <p> <form action='; echo $PHP_SELF; Print ' method=post> <table> <tr><td>Name:</td><td><input type="text" value="'; Print $name; print '" name="name" /></td></tr> <tr><td>Phone:</td><td><input type="text" value="'; Print $phone; print '" name="phone" /></td></tr> <tr><td>Email:</td><td><input type="text" value="'; Print $email; print '" name="email" /></td></tr> <tr><td colspan="2" align="center"><input type="submit" /></td></tr> <input type=hidden name=mode value=edited> <input type=hidden name=id value='; Print $id; print '> </table> </form> <p>'; } if ( $mode=="edited") { mysql_query ("UPDATE address SET name = '$name', phone = '$phone', email = '$email' WHERE id = $id"); Print "Data Updated!<p>"; } 
if ( $mode=="remove") { mysql_query ("DELETE FROM address where id=$id"); Print "Entry has been removed <p>"; } 
$data = mysql_query("SELECT * FROM address ORDER BY name ASC") or die(mysql_error()); Print "<h2>Address Book- Created by Priya Varier</h2><p>"; Print "<table border cellpadding=3>"; Print "<tr><th width=200>Name</th><th width=200>Phone</th><th width=160>Email</th><th width=200 colspan=2>Admin</th></tr>"; Print "<td colspan=5 align=right><a href=" .$_SERVER[’PHP_SELF’]. "?mode=add>Add Contact</a></td>"; while($info = mysql_fetch_array( $data )) { Print "<tr><td>".$info['name'] . "</td> "; Print "<td>".$info['phone'] . "</td> "; Print "<td> <a href=mailto:".$info['email'] . ">" .$info['email'] . "</a></td>"; Print "<td><a href=" .$_SERVER[’PHP_SELF’]. "?id=" . $info['id'] ."&name=" . $info['name'] . "&phone=" . $info['phone'] ."&email=" . $info['email'] . "&mode=edit>Edit</a></td>"; Print "<td><a href=" .$_SERVER[’PHP_SELF’]. "?id=" . $info['id'] ."&mode=remove>Remove</a></td></tr>"; } Print "</table>"; ?>

 
</body> </html> 
 
 </div>
 <div class="clearer"></div>
</div>
<div id="footer">Created by Priya Varier.  All rights reserved.</div>
</body>
</html>
 

The image I have used is header-copy.jpg, which I am attaching. Am I allowed to give the link to my page which is online? I thought it was not allowed in the sitepoint forums.

As to the markup, we need to see the actual marked up content the browser receives. Server side stuff means nothing.

It seems obvious, though, that the table is wider than its container, thus overflowing beyond the bg image’s width.

cheers,

gary

Your image is only 750px wide, while the wrapper, etc. is 760px wide. Set the #outer {width: 750px;}, and delete the width property from everything else except the footer. Put the footer inside wrapper and you can delete its width, too.

On table, set {margin: 0 auto;}.

cheers,

gary

Hi Priya, only just picked up the visitor message so sorry for the delay!

You can post a link for your site as it is needed to help you solve the problem (although Gary looks like he has already done it!)

The self promotion rule is more for people promoting their own sites and services.

Thanks a lot, Gary.

I changed the widths everywhere to 750 px and now I am not getting that extra margin.

But I have a couple of doubts.

On table, set {margin: 0 auto;}.

I am sorry but with my newbie knowledge, I did not really understand where exactly I needed to set that. But even without that, I am getting my page to look right. Is it necessary to do that and if so, where exactly do I do it?

you add that to your body tag style. it’s always good to add that. :smiley:

It looks like that page is using a sticky footer so the footer will need to stay outside the wrapper and maintain its width :slight_smile:

It does need updating with the following rules for ie8 and opera though.


/*Opera sticky footer Fix*/
body:before {
    content:"";
    height:100%;
    float:left;
    width:0;
    margin-top:-32767px;
}
/* ie8 sticky footer fix*/
#outer:after {
    clear:both;
    display:block;
    height:1%;
    content:" ";
}


But even without that, I am getting my page to look right. Is it necessary to do that and if so, where exactly do I do it?

margin:0 auto will center a fixed width element in the available space. If your tables are 750px wide then they won’t need to be centred because they will already be centred by the page wrapper.

My bad. I removed the table’s width, along with anything else’s within the wrapper. If the font size is then reduced, e.g. ctl -, the table shrink wraps and the auto margin keeps it centered.

cheers,

gary