Click to See Complete Forum and Search --> : Height Problem
LizzyB
11-10-2007, 08:43 AM
Hi,
I am trying to get my page to be 100% high. I mean to fill the screen with both my left and right navs and content.
Trouble is that they are going more than 100% and are not all in line at the bottom. I think my header div is causing some of the problem because that is 200px high and it looks to me like my whole page is 100% plus th 200px high. But if i dont specify a height for my header (image) it wont show.
I have a feeling Im not coding the height/min-height on my divs correctly. Id be grateful if someone can tel me what ive done wrong.
the page can be seen here:
http://www.whizzliz.co.uk/FoodSurveys/index.php
Thanks
Liz
Remove all min-height:1000%;
Change this:html, body {
height: 100%;
background-color:#403D77;
}
body {
padding: 0px;
background-color:#fff;
border:5px solid #999999;
margin:10px auto;
width:850px;
position:relative;
}
#wrapper{
/* don't need this */
}
LizzyB
11-10-2007, 09:17 AM
Thank you Fang - that has worked a treat.
I had no idea you could set body to a smaller width.
Looks like i was trying to over complicate things.
Thanks again
Liz
LizzyB
11-10-2007, 09:23 AM
Oops.
I have found a problem now that the content and right nav background color doesnt stretch to the bottom of the page on this page
http://www.whizzliz.co.uk/FoodSurveys/training.php
And on this page
http://www.whizzliz.co.uk/FoodSurveys/quality.php
the content spills out below everything else...
Any ideas on these bits?
Liz
That's because you are using absolute positioning.
Floating is easier to control:html {
height: 100%;
background-color:#403D77;
}
body {
height:auto !important; height:100%;
min-height:100%;
margin: 0px;
padding: 0px;
background-color:#fff;
border:5px solid #999999;
margin:10px auto;
width:850px;
}
#wrapper{
overflow:hidden;
}
#header{
background-image:url(header2.jpg);
width:850px;
height:200px;
}
#leftnav{
float:left;
margin-right:-3px; /* fix IE6 duplicate character bug */
width:200px;
background-color:#FFFFFF;
}
#rightnav{
float:right;
width:200px;
background-color:#EBEBEB;
}
#content{
float:left;
margin-right:-3px; /* fix IE6 duplicate character bug */
width:430px;
padding:10px;
background-color:#EBEBEB;
}
LizzyB
11-10-2007, 12:03 PM
Hi,
Thanks again for your response. However Im still having some problems with this. Now the content doesnt spill over on the longer pages but I only get the background colour as far as the text goes - so its still short on the pages with little content and on the pages that are long the right nav colour stops short.
Theres also now a small gap between the content and right column of about 3pxs......
Also - i really want to understand how the whole height / min height thing works whether I choose to use float or absolute for my postioning.
Regards
Liz
(who's thinking of reverting back to simple tables!)
LizzyB
11-10-2007, 12:15 PM
btw - here is the original code as I keep changing it on the initial link while i try stuff out!
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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="style_FS.css" rel="stylesheet" type="text/css" />
<title>Untitled Document</title>
</head>
<body>
<div id="wrapper">
<div id="header"></div> <!-- header -->
<div id="leftnav">
<div class="navbox">
<a href="quality.php">Quality Assurance Programmes</a>
</div>
<div class="navbox">
<a href="staffing.php">Quality Assurance On Demand</a>
</div>
<div class="navbox">
<a href="lossassessment.php">Loss Assessment</a>
</div>
<div class="navbox">
<a href="#">Food Safety Training</a>
</div>
<div class="navbox">
<a href="#">International Business Development</a>
</div>
<div class="navbox">
<a href="#">Hygiene Audits</a>
</div>
</div> <!-- left nav-->
<div id="rightnav">
<div class="navbox2">
<h3>Customer Testimonials</h3>
<p>Rotating content to be provided.</p>
<p>» <a href="#">More</a></p>
</div>
<div class="navbox2">
<h3>News</h3>
<p>Content to be updated monthly</p>
<p>» <a href="#">More</a></p>
</div>
<div class="navbox2">
<h3>Training Programs</h3>
<p>Dates etc to be updated regularly</p>
<p>» <a href="#">More</a></p>
</div>
</div> <!-- right nav-->
<div id="content">
<p>Food Surveys is a privately owned and independent company providing inspection, assessment and consultancy solutions to the food industry around the world. </p>
<p>Over the past 12 years the company has become a leading supplier of quality assurance, product inspection, hygiene auditing, food industry training and the provision of temporary technical personnel to major food companies and government agencies both within the United Kingdom and internationally. Our organisation has the facility to offer a true ‘farm to fork’ level of service.</p>
<p>The company continually focuses on adding value, to ensure that compliance to a technical standard or legislative requirement is combined with the commercial benefits of good operation, be this reduced wastage, more efficient management or a competitive advantage gained through improved product quality and safety.</p>
</div> <!-- content -->
</div><!-- wrapper -->
</body>
</html>
CSS
/* LAYOUT */
html, body {
height: 100%;
}
body {
margin: 0px;
padding: 0px;
background-color:#403D77;
}
#wrapper{
width:850px;
min-height:100%;
margin:10px auto;
position:relative;
border:5px solid #999999;
}
#header{
background-image:url(images/header2.jpg);
width:850px;
height:200px;
position:absolute;
top:0px;
left:0px;
}
#leftnav{
width:200px;
min-height:100%;
position:absolute;
top:200px;
left:0px;
background-color:#FFFFFF;
}
#rightnav{
width:200px;
min-height:100%;
position:absolute;
top:200px;
right:0px;
background-color:#EBEBEB;
}
#content{
position:absolute;
top:200px;
left:200px;
width:430px;
padding:10px;
min-height:100%;
background-color:#EBEBEB;
}
.navbox{
width:160px;
margin:10px auto;
padding:10px;
background-color:#FFFFFF;
border-bottom:1px dotted #cccccc;
}
.navbox2{
width:160px;
min-height:100px;
margin:10px auto;
padding:10px;
background-color:#fff;
border:1px dotted #CCCCCC;
}
/** BASIC */
/* TEXTS */
body, th, td, input, textarea, select {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 0.80em;
line-height:1.3em;
color: #656565;
}
p, blockquote, ul, ol, dl {
margin-top: 0px;
text-align: justify;
}
strong {
color: #666666;
}
.text1 {
margin-bottom: 30px;
font-size: 14px;
font-weight: normal;
color: #D4D4D4;
}
.text2 {
color: #557400;
}
.text3 {
text-align: center;
color: #6E889A;
}
/** HEADINGS */
h1, h2, h3, h4, h5, h6 {
margin: 0px;
color: #595959;
}
h1 {
font-size: 2em;
font-weight: normal;
line-height:1.5em;
font-variant:small-caps;
margin-bottom:5px;
}
h2 {
font-size: 1.4em;
font-weight: normal;
line-height:1.5em;
font-variant:small-caps;
}
h3 {
font-size: 0.9em;
font-variant:small-caps;
}
/** LINKS */
a {
color: #595959;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
Thanks again for your response. However Im still having some problems with this. Now the content doesnt spill over on the longer pages but I only get the background colour as far as the text goes - so its still short on the pages with little content and on the pages that are long the right nav colour stops short.The css given will stretch the background to the full height of the browser window or the contents, which ever is longer.
Theres also now a small gap between the content and right column of about 3pxs......That's the fix for IE6. Conditional comments (http://msdn2.microsoft.com/en-us/library/ms537512.aspx) will fix that.
Also - i really want to understand how the whole height / min height thing works whether I choose to use float or absolute for my postioning.If you use absolute then you will have to use JavaScript to alter the background height.
(who's thinking of reverting back to simple tables!)http://www.hotdesign.com/seybold/
LizzyB
11-10-2007, 12:45 PM
Hi Fang,
The css given will stretch the background to the full height of the browser window or the contents, which ever is longer.
I dont know why but it just wasnt doing this. It was only doing the contents.
Anyway you have completely put me off using absolute positioning if you have to use javascript as i know many people turn it off these days so its just not worth it.
So I have just found my own fix for this which may horrify you/any purists.
I redid the layout using floats and put a bg image on the wrapper. Works a treat!
I had a look at you other link - i wont go back to tables but CSS is not easy!
Cheers
Liz
Doesn't work correctly in Firefox
LizzyB
11-10-2007, 04:12 PM
Hi - It looks ok to me in FF - can you tell me what looks wrong please?
Thanks
Centauri
11-10-2007, 07:43 PM
The minimum height of 100% on #wrapper means the inside of the wrapper will be at least 100% height of screen - the borders are added to this for the overall height. Add to this the top margin, and the bottom of your layout will always hang 20px below the bottom of the screen.
In IE6, the layout does not stretch this height as IE6 does not understand min-height. Feed it a fixed height (which it treats like minimum height) like this :* html #wrapper{
height:100%;
}