Connecting Tech Pros Worldwide Forums | Help | Site Map

100% not working

Member
 
Join Date: Jan 2008
Posts: 121
#1: Oct 2 '08
Hi,

Right i have just built a site which has 3 divs align to the left and in the outer 2 divs i have a background which i want to be a 100% so when the middle stretches so do the outer 2 but it does not happen. Please can you have a look at my code:

HTML
[HTML]
<!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>title</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="includes/css/styles.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#FFFFFF">
<div id="main">
<div id="header"></div>
<div id="navigation"></div>
<div id="header_image"></div>
<div id="clearer"></div>

<div id="body">
<div id="left_body"></div>

<div id="middle_body">
<div id="middle_body_title">
<div id="middle_body_title_inner">
<h3>title</h3>
</div>
</div>

<div id="body_text">
<div id="body_text_inner">content here </div>
</div>

<div id="menu">
<div id="menu_inner"> content here </div>
</div>

</div>
<div id="right_body"></div>
</div>

<div id="footer">
<div id="footer_inner"> footer </div>
</div>

</div>
</body>
</html>
[/HTML]

CSS
Expand|Select|Wrap|Line Numbers
  1. #main {width: 883px; margin: 0 auto; position: relative; padding:0px;}
  2. #header { height:117px; background-image:url(../../images/royal-berkshire-header.jpg); padding:0px; margin:0px; }
  3. #navigation { height:33px; background-image:url(../../images/navigation.jpg); margin:0px; padding:0px;}
  4. #header_image { height:244px; background-image:url(../../images/carpet-banner.jpg);margin:0px; padding:0px;}
  5.  
  6. #body { height:100%; overflow:auto; }
  7.  
  8. #left_body { width:75px; height:100%; background:url(../../images/left-body.jpg) repeat-y; margin:0px; padding:0px; float:left; }
  9. #middle_body { width:731px; height:100%; margin:0px; padding:0px; float:left;}
  10.  
  11.     #middle_body_title {height:50px; background:url(../../images/page-title.jpg); margin:0px; padding:0px;}
  12.     #middle_body_title_inner { line-height:30px; margin:0px; padding:8px;}
  13.     #middle_body_title_inner h3 { padding:0px; margin:0px; color:#615C44; font-size:18px; font-weight:normal; }
  14.  
  15. #right_body { width:77px; height:100%; background:url(../../images/right-body.jpg) repeat-y; margin:0px; padding:0px; float:left;}
  16.  
  17.  
  18.     #body_text { width:507px; background:#FAF7E8; padding:0px; margin:0px; float:left; height:100%;}
  19.     #body_text_inner { padding:8px; }
  20.  
  21.     #menu { width:224px; background:url(../../images/menu.jpg) repeat-y; padding:0px; margin:0px; float:left; height:100%;}
  22.     #menu_inner { padding:8px; }
  23.         #menu_inner ul { padding:0px; margin:0px; }
  24.         #menu_inner li { padding:4px; margin:0px; border-bottom:1px solid #E1D9B9; list-style:none; }
  25.     #menu_inner h3 { padding:0px; margin:0px; color:#615C44; font-size:18px; font-weight:normal; }
  26.  
  27. #footer {height:77px; text-align:center; background-image:url(../../images/footer.jpg); clear:both; font-size:11px;  padding:0px; margin-top:0px;}
  28.     #footer_inner { padding:8px; padding-top:15px; }
  29.     #footer_inner h2 { font-size:10px; font-weight:normal; padding:0px; margin:0px; }
  30.  
  31. #clearer {
  32.     clear:both;
  33.     line-height: 1px;
  34.     font-size: 1px;
  35. }
  36.  
Cheers,
Adam

Expert
 
Join Date: Aug 2008
Posts: 397
#2: Oct 3 '08

re: 100% not working


This going to be tedious. Bear with me.

Divisions have no margin or padding by default, so you can delete all instances of this in your style sheet.
Expand|Select|Wrap|Line Numbers
  1. #whatever {
  2. margin: 0px;
  3. padding:0px;
  4. ...
  5. }
  6. becomes
  7. #whatever {...}
  8.  
All versions of Opera and all versions of IE trip on line height set in pixels. Re-set line-height as a raw number. For example:
Expand|Select|Wrap|Line Numbers
  1. h1 {line-height: 2;}
  2.  
Content determines height. Delete all instances of the following throuhgout the style sheet
Expand|Select|Wrap|Line Numbers
  1. #whatever {
  2. height: auto;
  3. }
  4.  
Re-set #main as follows in order to contain the floats within it (the border is to see it):
Expand|Select|Wrap|Line Numbers
  1. #main {overflow: auto;}
  2. to
  3. #main {border: 1px solid #000; overflow: hidden;}
  4.  
The yellow box is auto expanding in IE/6 causing it expand and drop the float. The correction is:
Expand|Select|Wrap|Line Numbers
  1. #right_body {
  2. float:right;
  3. overflow-x: hidden;
  4. }
  5.  
STILL with me???

Add this to give the columns, asked about in your question, equal height:
Expand|Select|Wrap|Line Numbers
  1. #left_body,
  2. #right_body,
  3. #body_text,
  4. #body_text_inner {
  5. padding-bottom : 32767px;
  6. margin-bottom : -32767px;/*note minus sign*/
  7. }
  8.  
Add to position the footer on top of and paint over the columns:
Expand|Select|Wrap|Line Numbers
  1. #footer {border-top: 1px solid #000;
  2. position: relative;
  3. z-index: 1;
  4. #footer_inner,
  5. #footer_inner h2 { 
  6. background:#fff; 
  7. }
  8.  
Cross your fingers and hope neither of us forgot something....
Reply