I have been working on trying to get a page to display a title at the top of the content pane, and then a scrollable list of products below that so that the title of the product range is displayed at all times. I am sure this is a very simple thing to do - but cannot figure it out.
Currently the actual page (not the test page for which the code is given below) works ok in the sense that I set the heading div to 5% of the height of .content-container and then set the scrollable div to 95% with top: 5%, both with position: absolute applied.
However I would like to place some links in the heading div to different pages (1, 2, 3 etc), which I would like to center vertically if they are shorter than the heading and expand the heading div to match the height of the heading or the links, whichever is smallest. Furthermore I would like the div below the heading to shrink so that it doesn't go below the bottom of the content div as the heading div gets taller. The point of this is because it is for a client who may, or may not, be happy with the heading sizes and so on - therefore the heading div height could easily change. Specifying heights so precisely means that changing the h1 height could mean 5 changes to the CSS file - something I want to avoid.
The content pane currently has its height fixed to 80% of the page, with the header and footer being 10% each on top of that, so there is no scroll bar at the side of the page and the header / footer are always showing. This is something I would like to keep.
In the code below, .content-container is the main content pane - this is contained in another div which is centered using the margin at 50% of the page width. .test-div is the div which contains the heading. .test-div-2 is an attempt to place a div below .test-div, in the hope that I can force .test-div-3 to extend to 100% of its' height but no further, and to display a scroll bar if the content exceeds the height.
So far I have the following, but it doesn't do exactly what I would like it to:
<div class="content-container">
<div class="test-div">
<h1 style="text-align: center;">Dogs</h1>
</div>
<div class="test-div-2">
<div class="test-div-3">
//Content here
</div>
</div>
</div>
and here is the css :
.content-container {
position: absolute;
width: 100%;
height: 100%;
left: 0;
right: 0;
bottom: 0;
overflow: auto;
}
.test-div {
position: relative;
padding: 0;
margin: 0;
}
.test-div-2 {
position: relative;
background-color: #CCCCCC;
}
.test-div-3 {
max-height: 100%;
background-color: #999999;
}
Any help with this would be greatly appreciated. I would like to achieve this without the use of JavaScript / jQuery if possible - pure HTML / CSS solutions only please!
try
fixing the height of the scrolling div or any block level element and add overflow:scroll property or overflow-y:scroll property
Sample would be
.test-div-2
{
position: relative;
background-color: #CCCCCC;
overflow: scroll;
height: 100px;
}
.test-div-3
{
max-height: 100%;
background-color: #999999;
}
</style>
<div class="content-container">
<div class="test-div">
<h1 style="text-align: center;">
Dogs</h1>
<div class="clear">
</div>
</div>
<div class="test-div-2">
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue
massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero,
sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est. Vivamus
a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames
ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</p>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue
massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero,
sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est. Vivamus
a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames
ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</p>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue
massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero,
sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est. Vivamus
a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames
ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</p>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue
massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero,
sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est. Vivamus
a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames
ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. </p>
</div>
</div>
try this
.content-container
{
position: absolute;
width: 100%;
height: 100%;
left: 0;
right: 0;
bottom: 0;
overflow: auto;
}
.test-div
{
position: relative;
padding: 0;
margin: 0;
}
.test-div-2
{
position: relative;
background-color: #009933;
max-height:100px;
}
.test-div-3
{
max-height: inherit;
background-color: #0064ea;
overflow: scroll;
}
working example
jsFiddle
Related
I am trying to create a background that auto adjusts in height as I add content.
If there is no content, the background should cover the entire screen, 100vh. As I add content the background should adjust in height until it reaches its minimum height of 100px. I have included an image to show demo what I am trying to achieve.
I have tried using min/max/100%/auto height properties and cant seem to find a solution.
I am using vue 3, typescript and css in my project.
Can someone please help me?
Using flexbox would give you exactly what you are asking for. In a nut shell what is happening is the parent container is using display flex which causes the children use flexbox properties. The .background div then has flex-grow : 1 which pretty much says grow as much as you can to fill the container. That means it will grow to fill the left over space of the parent depending on how much text there is.
.flex-container {
display: flex;
height: 100vh;
flex-direction: column;
}
.background {
background-color: blue;
flex-grow: 1;
}
<div class="flex-container">
<div class="background">
<h1>my background div</h1>
</div>
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer
finibus, odio vel scelerisque convallis, leo odio scelerisque urna, ut
scelerisque elit urna id quam. Etiam tempus pretium erat a semper.
Mauris consequat scelerisque ante id volutpat. Suspendisse convallis,
ipsum ut vehicula vehicula, lorem mauris porttitor enim, sollicitudin
ultrices lectus sem et ipsum. Morbi feugiat, lorem at viverra mattis,
neque enim vehicula turpis, blandit luctus eros eros ut arcu. Praesent
facilisis pharetra consectetur. Maecenas sagittis commodo felis, vitae
tristique risus. Phasellus fermentum varius turpis vel rhoncus. Nullam
aliquet nec risus non interdum. Sed nec magna pellentesque, facilisis
felis ac, cursus leo. Fusce et tortor magna. Fusce odio eros, varius non
placerat mattis, ullamcorper sed purus.
</div>
</div>
You can use your text container to hide the background underneath.
.container {
border: solid 1px grey;
background-color: red;
position: relative;
height: 250px;
}
.text {
position: absolute;
bottom: 0;
background-color: white;
width: 100%;
}
<div class="container">
<div class="text">
<p>Here is some text <br /> on multiple <br /> lines.</p>
</div>
</div>
This question already has answers here:
Expand a div to fill the remaining width
(21 answers)
Closed 5 months ago.
I have a header div and a content div. The content div is wider than the window, so horizontal scrollbar appears, which is fine. I want the header div to occupy the full width, meaning it should stretch to the same width as the content div below it. By default divs are only wide as the window.
What is the simplest way to accomplish this? Can I do it without using JavaScript or tables? I would be fine using flex layout if that helps.
In the example below I want the red div to be the same width as the green div. Currently the red div stops at the edge of the window.
Note that in real code the content width is determined by the child elements I add to it, not set in CSS. This means I can't just set the width of the header div in CSS to match the width of the content div.
Additional clarification: When scrolling horizontally the header and content must scroll together, because header shows headings for the content below. When scrolling vertically the header stays in place (by using position sticky) while content scrolls.
<html>
<head>
<style>
body {
margin: 0;
}
.header {
background-color: red;
height: 50px;
}
.content {
width: 10000px;
height: 250px;
background-color: blue;
}
</style>
</head>
<body>
<div class="header"></div>
<div class="content"></div>
</body>
</html>
Is this what you're after?
* {
margin: 0;
padding: 0;
}
.content {
width: 2000px;
height: 1500px;
background: #eee;
position: relative;
}
.header {
width: 100%;
height: 50px;
background: #ccc;
position: sticky;
top: 0;
}
<div class="content">
<div class="header"></div>
</div>
Try this:
<head>
<style>
body {
margin: 0;
}
.header {
overflow-x: auto;
background-color: red;
height: 50px;
white-space: nowrap;
}
.content {
overflow-x: auto;
height: 250px;
background-color: blue;
white-space: nowrap;
}
</style>
</head>
<body>
<div class="header">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Egestas fringilla phasellus faucibus scelerisque eleifend donec. Nulla aliquet enim tortor at auctor urna. Mattis vulputate enim nulla aliquet. Sit amet massa vitae tortor condimentum lacinia quis vel eros. Tempor id eu nisl nunc mi ipsum. Adipiscing enim eu turpis egestas pretium. Sed odio morbi quis commodo odio aenean sed adipiscing. Pellentesque diam volutpat commodo sed egestas egestas. Felis imperdiet proin fermentum leo vel. Pellentesque pulvinar pellentesque habitant morbi tristique senectus et netus et. Gravida dictum fusce ut placerat orci. Blandit massa enim nec dui nunc mattis. Ut morbi tincidunt augue interdum velit euismod in pellentesque.</p>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Egestas fringilla phasellus faucibus scelerisque eleifend donec. Nulla aliquet enim tortor at auctor urna. Mattis vulputate enim nulla aliquet. Sit amet massa vitae tortor condimentum lacinia quis vel eros. Tempor id eu nisl nunc mi ipsum. Adipiscing enim eu turpis egestas pretium. Sed odio morbi quis commodo odio aenean sed adipiscing. Pellentesque diam volutpat commodo sed egestas egestas. Felis imperdiet proin fermentum leo vel. Pellentesque pulvinar pellentesque habitant morbi tristique senectus et netus et. Gravida dictum fusce ut placerat orci. Blandit massa enim nec dui nunc mattis. Ut morbi tincidunt augue interdum velit euismod in pellentesque.</p>
</div>
</body>
When the .content div overflows a scrollbar will be added for that div only instead of the entire body. You can do the same for .header.
referring to the following question made by me where i was asking on how could i fit the content between the header and the footer by setting content height minus footer height solved the problem but actually when i try to add the web site to Home screen on any iPhone the footer goes out of screen as the following:
As you can see the footer is visible only in part and to see it i have to scroll the whole page down (not the central content but the page) while that problem doesn't persist on web or Android devices..
I've tryed to subtract more pixels to content height if the device is an iphone but it had no effect, i've tryed the following code:
if (navigator.userAgent.match(/iPhone/i)) {
$('.tableFixHead').addClass('tableFixHead-mobile');
}
.tableFixHead-mobile {
max-height: calc(100vh - 500px) !important;
}
But the view remain still the same, the whole css and html code you can see in the following jsfiddle
If I understand your question correctly, the goal is to always have the header and footer fixed and allow the content in the center to scroll. You've accomplished this with absolute positioning and calculations based on viewHeight
The problem is that the implementation of vh is extremely inconsistent on mobile devices. And these problems are unlikely to change any time soon (see this).
So, I would recommend revamping your layout to reduce the dependency on viewHeight. There are multiple ways to do this but flexbox would give you an easy solution.
Here's a minimal example of how to implement this. You'll have to apply it to your code as needed.
.contentWrapper {
/* this needs to fill the viewport
position fixed will work on modern mobile devices. */
position: fixed;
top:0; right:0; bottom:0; left:0;
/* add flex-box */
display:flex;
flex-direction:column;
}
header, footer {
background-color: darkgray;
flex-basis: 50px;
padding: 20px;
box-sizing: border-box;
}
.mainContentArea {
/* set this to fill the center space */
flex-basis: calc(100% - 100px);
/* make it scroll */
overflow-y: auto;
}
<div class="contentWrapper">
<header>Fixed Header</header>
<div class="mainContentArea">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pellentesque nec quam et imperdiet. Nullam vel euismod nisl, sed viverra magna. Cras nec ex ligula. In laoreet ornare nunc ut pellentesque. Phasellus lobortis vehicula lacus, et tempor dui scelerisque sit amet. Cras porttitor leo a mauris eleifend, sed sodales mi tempor. Morbi molestie, est sit amet consequat viverra, lacus arcu lobortis sapien, quis maximus dui sem nec erat. Nullam blandit tellus et dui lacinia aliquam. Morbi non gravida nisl, ac viverra tellus. Donec viverra diam ut malesuada bibendum. Sed vehicula orci eu enim aliquam, ac faucibus mauris molestie.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pellentesque nec quam et imperdiet. Nullam vel euismod nisl, sed viverra magna. Cras nec ex ligula. In laoreet ornare nunc ut pellentesque. Phasellus lobortis vehicula lacus, et tempor dui scelerisque sit amet. Cras porttitor leo a mauris eleifend, sed sodales mi tempor. Morbi molestie, est sit amet consequat viverra, lacus arcu lobortis sapien, quis maximus dui sem nec erat. Nullam blandit tellus et dui lacinia aliquam. Morbi non gravida nisl, ac viverra tellus. Donec viverra diam ut malesuada bibendum. Sed vehicula orci eu enim aliquam, ac faucibus mauris molestie.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pellentesque nec quam et imperdiet. Nullam vel euismod nisl, sed viverra magna. Cras nec ex ligula. In laoreet ornare nunc ut pellentesque. Phasellus lobortis vehicula lacus, et tempor dui scelerisque sit amet. Cras porttitor leo a mauris eleifend, sed sodales mi tempor. Morbi molestie, est sit amet consequat viverra, lacus arcu lobortis sapien, quis maximus dui sem nec erat. Nullam blandit tellus et dui lacinia aliquam. Morbi non gravida nisl, ac viverra tellus. Donec viverra diam ut malesuada bibendum. Sed vehicula orci eu enim aliquam, ac faucibus mauris molestie.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pellentesque nec quam et imperdiet. Nullam vel euismod nisl, sed viverra magna. Cras nec ex ligula. In laoreet ornare nunc ut pellentesque. Phasellus lobortis vehicula lacus, et tempor dui scelerisque sit amet. Cras porttitor leo a mauris eleifend, sed sodales mi tempor. Morbi molestie, est sit amet consequat viverra, lacus arcu lobortis sapien, quis maximus dui sem nec erat. Nullam blandit tellus et dui lacinia aliquam. Morbi non gravida nisl, ac viverra tellus. Donec viverra diam ut malesuada bibendum. Sed vehicula orci eu enim aliquam, ac faucibus mauris molestie.</p>
</div>
<footer>Fixed Footer</footer>
</div>
.footer {
z-index: 9;
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
line-height: 60px;
background-color: #f5f5f5;
}
The above is your code. Just change from position:absolute to position:fixed.
Run the following snippet, if your question was correctly understood then the result is the visual effect you want to achieve. If yes, then check the dimensions of the elements and their position in the code below.
* {
margin: 0;
padding: 0;
}
body {
display;
flex;
align-items: center;
align-content: center;
justify-content: stretch;
flex-direction: column;
text-align: center;
width: 100%;
height: 100%;
}
header,
footer {
background: #000;
color: #fff;
height: 3rem;
width: 100%;
}
main div {
padding: .5rem 0;
}
main {
background: orange;
width: 100%;
min-height: calc(100% - 6rem);
height: auto;
position: relative;
top: 3rem;
margin-bottom: 2rem;
overflow: hidden;
}
main p {
height: 2rem;
}
header {
position: fixed;
top: 0;
z-index: 1;
}
footer {
position: fixed;
top: calc(100% - 3rem);
}
<header>this is header content</header>
<main>
<div>
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
<p>7</p>
<p>8</p>
<p>9</p>
<p>10</p>
<p>11</p>
<p>12</p>
<p>13</p>
<p>14</p>
<p>15</p>
<p>16</p>
<p>17</p>
<p>18</p>
<p>19</p>
<p>20</p>
</div>
</main>
<footer>this is footer content</footer>
Reading this SO it seems that when setting position: absolute, you must add left: 0 and right: 0 properties to .footer in order that the bottom: 0 will work on iphone and ipad.
Didn't test it myself yet, but it was upvoted so i guess someone else found that useful.
After digging more SO's i found also this that related to this issue.
Worth to mention that caniuseit shows that from version 11 there is full support of absolute position and they not mention any sort of the above..
I guess you will test it before me, hope that will do it.
EDIT: As those SO that i linked above (also) mention, and also following the docs, in order for the position: absolute would work as expected, it parent element should have any position - and that make sens.
Seems that form id="form" is the parent (base on this fiddle), so i would add position: relative; to body itself.
Hope that will work.. Can't test it myself.
I am looking to accomplish a few things-
Set a container to fit 100% of viewport height and width;
Center the h1 vertically and horizontally in that container;
Add a paragraph of text beneath the h1 without this paragraph pushing the h1 up or breaking the centering.
Here's a diagram
I've already tried many of the methods discussed here and elsewhere (tables, display: table/table-cell + vertical align, using an inline-block with vertical align, etc) but the problem is that all of them either center both the h1 and the paragraph, or adding the paragraph under the h1 breaks it entirely. As the site is responsive, the h1 will likely become multiple lines of text on smaller screens. Is there a way to keep the h1 at the vertical and horizontal center while still adding content beneath it?
Well, basically just give the p a height of zero. The max-width below is just for illustration, margin: 0 auto then centers that horizontally.
html, body {
height: 100%
}
.container {
display: table;
height: 100%;
width: 100%;
}
.v-center {
display: table-cell;
vertical-align: middle;
text-align: center
}
p {
height: 0;
max-width: 200px;
margin: 0 auto;
}
<div class="container">
<div class="v-center">
<h1>Heading</h1>
<p>
Paragraph paragraph paragraph paragraph paragraph paragraph
paragraph paragraph paragraph paragraph paragraph paragraph...
</p>
</div>
</div>
The use of flexbox is your best bet as it is very concise and has good browser support. Also, it's your best bet for future-thinking as it is forming the foundation of today's modern app layout infrastructure.
The <p> being not pushed down is just done by giving a 0 height so that its effects on its container is not realized.
HTML:
<div class="container">
<h1>
HI
</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras neque tortor, auctor ut consectetur non, posuere a justo. Morbi nisi eros, pellentesque eget ullamcorper eu, tristique at tortor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent ornare odio lorem, vel fermentum est lacinia ut. Vivamus tincidunt augue scelerisque justo consectetur tincidunt. Phasellus lectus nibh, ultrices in dictum vel, pretium at nisl. Sed vehicula tortor sed facilisis accumsan. Sed cursus felis quis quam efficitur, id luctus mi aliquet. Morbi mattis gravida convallis. Sed non feugiat dolor, in gravida arcu. Morbi id dolor imperdiet, rhoncus ante convallis, varius lacus.
</p>
</div>
CSS:
.container {
align-items: center;
background: red;
display: flex;
flex-direction: column;
justify-content: center;
height: 100vh;
width: 100vw;
}
.container p {
height: 0;
}
Fiddle: https://jsfiddle.net/3ms3sggd/
A Great Flexbox Guide: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
You can put the p and h1 in a div, then give to the div margin-top equal to 50% viewport and margin-left/right auto
* {
margin: 0;
padding: 0
}
div {
background-color: #fff;
width: 400px;
height: 100px;
margin-top: 50vh;
margin-left:auto;
margin-right:auto;
text-align: center
}
h1{
margin-bottom: 20px
}
<div>
<h1>
header
</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
</p>
</div>
with flex, things can be easy, text underneath can be setted in absolute position and html will scroll if needed:
html {
display:flex;
height:100%;
/* see center */
background:linear-gradient(to left, transparent 50%, rgba(0,0,0,0.2) 50%),linear-gradient(to top, transparent 50%, rgba(0,0,0,0.2) 50%)
}
body {
margin:auto;/* will shrink and center body on both axis */
/* see me ? */
background:rgba(0,0,0,0.2)
}
p {
position:absolute;
left:0;
right:0;
width:80%;/* set a width eventually */
margin:auto;/* if you did set a width, then can be useful */
}
h1 {
/*margin reset ? */
margin:0;
}
<h1>HI !,test me full page too</h1>
<p>Lesquelles habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
Note, what works here is p {position:absolute;} and the fact that HTML will show a scroll bar if p goes beyond bottom. Flex makes it easy to center h1, but other centering technic within the flow will do (inline-block or table/table-cell ) with html {height:100%} as a basis ...
So you can a full site laying under your midle center h1 :
html {
display: flex;
padding: 0;
height: 100%;
box-sizing: border-box;
background: linear-gradient(to left, transparent 50%, rgba(0, 0, 0, 0.2) 50%), linear-gradient(to top, transparent 50%, rgba(0, 0, 0, 0.2) 50%) fixed
}
body {
margin: auto;
text-align: center;
}
.below {
position: absolute;
left: 0;
right: 0;
width: 80%;
margin: auto;
text-align: left;
}
<h1>HTML Ipsum Presents</h1>
<div class="below">
<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris
placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis
tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.</p>
<h2>Header Level 2</h2>
<ol>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
</ol>
<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis
elit sit amet quam. Vivamus pretium ornare est.</p>
</blockquote>
<h3>Header Level 3</h3>
<ul>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
</ul>
<pre><code>
#header h1 a {
display: block;
width: 300px;
height: 80px;
}
</code></pre>
</div>
This is driving me crazy. I'm trying to get the footer div to be at the bottom of the page even if the main content doesn't fill the height of the browser. The below code works except for when I shrink the browser up and then the footer div overlaps the wrapper div, then the scroll bar appears. I want it to bump up against the wrapper div like most sites including this one. What am I doing wrong?
<html>
<head>
<style>
body { color:#000; margin: 0; height: 100%; }
#wrapper {min-height: 100%; height: auto !important; height: 100%; background:#ff0000;
margin: 0 auto -4em; text-align: left; width: 100%; }
#header { width: 100%; height: 80px; }
#content { width: 100%; background:#00ff00; }
#footer { background:#0000ff; height: 4em; }
</style>
</head>
<body>
<div id="wrapper">
<div id="header">
some menus;
</div>
<div id="content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ac eros diam, nec ultrices nibh. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed id ipsum libero. Sed ultricies orci ut magna vulputate eu congue justo condimentum. Phasellus a convallis ipsum. Nam nec sapien eget massa porta tristique. Proin metus diam, imperdiet nec eleifend a, faucibus eget quam. Nunc non lacus sit amet lorem vehicula viverra ut vitae sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi id tellus id ligula dictum consequat non ut ligula. Morbi interdum felis sed turpis sagittis vulputate.
</div>
</div>
<div id="footer">
© 2009 Somebody
</div>
</body>
</html>
http://ryanfait.com/resources/footer-stick-to-bottom-of-page/
Check out this live example of how it works:
http://www.toonklaas24.ee/