473,402 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Tables VS. CSS (Footer at the bottom, 100% of the viewport)

I've tried to get CSS to give me a basic layout where I can place a
footer at the bottom of the page and the top of the page I can use for
content. I don't however want the footer to pull away from the bottom
of the viewport if the top content is small. Also, when I resize the
window I want the footer to move with the bottom of the page until I
reach the content.

Here is an example that works both in IE and Mozilla using tables. I
aslo had to use quirks mode for IE. I want to get rid of quirks mode
and use div's. Personally I don't think it can be done.

code:

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<style type="text/css">
body{margin:0px;padding:0px;}
table{border-collapse:collapse;height:100%}
td{padding:0px}
#top{ background-color:red;vertical-align:top}
#bottom{height:100px;
background-color:yellow;vertical-align:top}
</style>
</head>
<body>
<table>
<tr id="top">
<td>
<h1>header</h1>Takes up the viewport minus the footer
</td>
</tr>
<tr id="bottom">
<td>
<h1>footer</h1>Located at the bottom
</td>
</tr>
</table>
</body>
</html>
Jul 20 '05 #1
5 14384
"Tyler Carver" <xf**********@yahoo.com> wrote in message
news:81**************************@posting.google.c om...
I've tried to get CSS to give me a basic layout where I can place a
footer at the bottom of the page and the top of the page I can use for
content. I don't however want the footer to pull away from the bottom
of the viewport if the top content is small. Also, when I resize the
window I want the footer to move with the bottom of the page until I
reach the content.


The following roughly thrown together page works for IE6 but isn't quite
right for Opera7.54 or Netscape7.1
Opera needs the page refreshing after it loads or the window is resized
and Netscape brings up a vertical scroll bar.

I'm not sure why it doesn't work properly, being new-ish to CSS myself, so
will watch for any replies with interest.

=================

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Test Page</title>
</head>

<body>

<div style="width:100%; position:absolute; bottom:0; text-align:center">THIS
IS THE BOTTOM!</div>

</body>
</html>
Jul 20 '05 #2
xf**********@yahoo.com (Tyler Carver) writes:
I've tried to get CSS to give me a basic layout where I can place a
footer at the bottom of the page and the top of the page I can use for
content. I don't however want the footer to pull away from the bottom
of the viewport if the top content is small.
Have multiple advice with decreasing value:

1) Stop wanting that
2) Keep using a table
3) <http://sandbox.bednarz.nl/css/height/footer.html>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> \
The FPI is case sensitive
table{border-collapse:collapse;height:100%} #bottom{height:100px;
background-color:yellow;vertical-align:top}


You're better off declaring basically

body
{
margin: 0;
padding: 0;
}
html,
body,
table
{
height: 100%;
}
#bottom
{
vertical-align: bottom;
}

and then finetune the appearance of the box that is stuck in #bottom.
--

PiĆ¹ Cabernet,
meno Internet.
Jul 20 '05 #3
Eric B. Bednarz <be*****@fahr-zur-hoelle.org> wrote in message news:<m3************@email.bednarz.nl>...

Have multiple advice with decreasing value:

1) Stop wanting that
I've had this response a number of times. Which is why I think css is
inadequate and has a long way to go. Many reasonable and simple
things are next to impossible (especially with layout).
2) Keep using a table
It seemed I had no other option. It was solved in two seconds with a
table but I had to leave IE in quirks mode (which I hate).

3) <http://sandbox.bednarz.nl/css/height/footer.html>
This page didn't load.
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">

\
The FPI is case sensitive


Thanks for the tip. Stupid Visual Studio .Net formatting (which you
can't completely turn off).
Jul 20 '05 #4
xf**********@yahoo.com (Tyler Carver) wrote:
1) Stop wanting that
I've had this response a number of times. Which is why I think css is
inadequate and has a long way to go.


Does it? A footer should be positioned relative to the content,
positioning it relative to the viewport makes no sense on the web where
you have no idea of or control over the viewport height.
Many reasonable and simple
things are next to impossible (especially with layout).


Most problems are not the result of lack css inadequacies, but because
css support in IE is relatively poor.

--
Spartanicus
Jul 20 '05 #5
On 2 Sep 2004 09:21:48 -0700, Tyler Carver <xf**********@yahoo.com> wrote:
Eric B. Bednarz <be*****@fahr-zur-hoelle.org> wrote in message
news:<m3************@email.bednarz.nl>...

Have multiple advice with decreasing value:

1) Stop wanting that


I've had this response a number of times. Which is why I think css is
inadequate and has a long way to go. Many reasonable and simple
things are next to impossible (especially with layout).


Depends on how you define "reasonable". By putting an element as low as
possible - with variable space between it and the preceding content - you
are essentially asking the browser to tack it onto the bottom chrome or
lower. That's not a content-driven design.

Regardless of how attractive it is, that's not how CSS was designed.
Ultimately, what is lost if the footer bar is not flush to the bottom
chrome? Other than a perceived notion that there's wasted space below
(which is not really wasted, just extra)? You still have a very usable
page.

Remember, CSS thinks of the height of the page based on the content, not
on the viewport. Which makes all sorts of sense if you really think about
it.
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

82
by: Peter Diedrich | last post by:
The site design is pretty simple: ============================================ | Head | ============================================ | | ...
1
by: Ron Bott | last post by:
I have a layout that has a fixed size #container <div> with a shadow running along the right side that encloses the content area. I would like the shadow background to extend to the full height of...
3
by: Gary Finnigan | last post by:
I have a three column layout that is preventing the footer from showing. The page is at www.clickatdepaul.org Can anyone suggest what might be the problem|? Gary -- Regards Gary Finnigan...
31
by: Neil | last post by:
I have an Access 2000 MDB with ODBC linked tables to a SQL Server 7 back end. I currently have a selections table in the front end file which the users use to make selections of records. The table...
4
by: steve | last post by:
Hi All I am having annoying problems with VS 2005 (VB) positioning tables on a web page If I create HTML tables for layout, sometimes the next table sits at the bottom of the above table and...
1
by: abc | last post by:
I don't know How to use HTML's DIV Tag to do that web page which have header (Top), content (datagrid) with scroll bar, and bottom footer. How should I do?
1
by: Okie | last post by:
I'm trying to make a three panel page. Two panels on the left (top and bottom) and a content panel on the right. I want the viewport to never scroll. The left menu (two panels vertically) set at...
11
by: Michael7 | last post by:
Hi everyone, Me again, been a while since I've been here, but I'm back again needing help with a simple thing. I've searched for help on creating a footer, but all the help I've found, was...
1
by: soms2m | last post by:
HELLO ALL, I want to fill the parent window height with respect to the sub window height which is loading using ajax (mootools). For example if the parent window height is normal and the loading...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.