473,407 Members | 2,312 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,407 software developers and data experts.

100 percent width, 100 percent height css

348 100+
Hello everyone,


I have a question regarding css where I would like to know if it is possible to break up a page into thirds for the height. I need to have a page that will be 100% in height and 100% in width. The height will be broken down into thirds; 20% for the header image, 75% for the content and the remaining 5% for the footer image.

I am not a real big css buff and have always used tables for everything until recently when I started validating all of my html. Part of what is so frustrating to me with regard to css is the fact that what works in one browser will not work in another browser. How do you guys remember all the hacks?

My needs are actually pretty simple. I need this to work in either IE 6, IE7 and FF. That is all.

What I have is a div container that is set to 100% height and 100% width. Inside of that div, I have a table that uses css to stretch it 100% high and 100% wide. It works perfect..

The problem I am having is that when I try and devide the 3 table rows (header, content and footer) it will not render correctly. I can't even see my header image unless I set the height to about 90%.

Would someone please give me a hand?

Thanks,

Frank
Jun 19 '08 #1
4 20017
dlite922
1,584 Expert 1GB
It takes some getting use to. I convert it from tables to divs about a year ago and at first it was a pain, but I think at the end its worth it.

Now I only use tables for actually tabular data, if there is any, in the page, but the layout is all Divs.

It has almost become a standard to first enclose ALL your site data (from body tag to body tag) inside one div.

Inside there, you'll have three main sections like you mentioned, BUT it is a bad idea to divide them percentage wise.

Your header is usually constant, and leave it at a FIXED height (in em or px) or set it at auto and let the content of the header hold it down.

Same with the footer.

the "content" section (the middle section) (don't call it body for obvious reasons), is the most variable height and you should set its height to "auto".

This will rap around.

Avoid using position: absolute, its a headache and will cause you alot of issues between browsers.

Other issues are with margins. use padding as much as you can instead of margins, because IE parses margins differently.

For example, you'll see that a text area in your content is shifted to the right even if you set its margin to 0, while FF, does not do it.

This is usually because some of its parent tags, or the content section are have a margin.

In summary, use padding unless you have a background for it.

Try to make everything work with position: relative, float: left, or clear: both.

Since you didn't provide any code, i can't help you out, here's a really good site that puts most of your problem in one page.

Follow the links to go the actual site that addresses the problem, this is just a list:

http://www.noupe.com/css/using-css-t...and-fixes.html

Good luck,


Dan
Jun 19 '08 #2
fjm
348 100+
Hi Dan, thank you so much for the pointers and the help! I will certainly keep those in mind. I am absolutely stumped over why this will not work. Since I have posted this, I have been to several other forum sites and have gotten ideas and some things work in IE and others don't in FF. Here is my actual code:

Expand|Select|Wrap|Line Numbers
  1. html,body        {background-color:#ffffff; margin:0; padding:0; height:100%; border:none; font-size: 11px; font-family: "Trebuchet MS", "Times New Roman", Arial, Times, serif;}
  2. table#container  {width:100%; height:100%; margin:auto;}
  3. tr#headerbg      {background-image: url('../../images/headerbg.gif'); background-repeat: repeat-x; vertical-align: bottom;}
  4. td#headerheight  {vertical-align: bottom; line-height: 0;}
  5. div#headerlogo   {background-image: url('../../images/header.gif'); background-repeat: no-repeat; vertical-align: bottom;}
  6.  
  7. tr#contentbg     {height:80%; background-color: #fff7f7; vertical-align: top;}
  8. td#contentheight {height:80%; vertical-align: top; line-height: 0; vertical-align: top;}
  9.  
  10. tr#footerbg      {height:3%; background-color: #0a326b; vertical-align: bottom;}
  11. td#footerheight  {height:3%; vertical-align: bottom; line-height: 0;}
I absolutely agree with you about using px size instead of percentage. Even still, I cannot get the images to display; especially the header. The footer displays just fine.

Thanks a million,

Frank
Jun 19 '08 #3
fjm
348 100+
Wow, I was able to get it working by dumping the table design and using divs. I have a second question though.

In a div, I am using a background image. The image is about 300px. Because I am using a 100% width, I need an image to complete the rest of the image.

Here is what draws the image. I need a second image to pick up where this one leaves off.

Expand|Select|Wrap|Line Numbers
  1. #header    {width: 100%; height: 12%; min-height:0; background-image: url('../../images/header.gif'); background-repeat: no-repeat;}
How would I do this? Should I create a nested div?
Jun 20 '08 #4
fjm
348 100+
Yes Frank, a nested div is what you need.

:)
Jun 20 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: ohaya | last post by:
Hi, I was wondering what happens when width and height in a style (e.g., in a DIV) are set to '0px'? For example something like: style="position: absolute; width: 0px; height: 0px;" ...
3
by: coolsti | last post by:
I need some help here. I am making an application which allows a user to look at a series of picture files one at a time, and enter the outcome of various visual tests to a database. The...
2
by: Clemens Quoss | last post by:
Hello, I just encountered a strange thing when switching the doctype on and off in the following html testpage (with IE 6.0): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"...
1
by: Ken Varn | last post by:
This is probably a common question, but bear with me. I am new to this stuff. I want to convert a Unit Width and/or Height to an actual pixel Int32 Width and Height. I was just using the Value...
2
by: Robson Carvalho Machado | last post by:
Dear friends, I'm dynamically creating a Hyperlink with spacer.gif as ImageURL that is an 1px transparent image only to determine link position, but as I create this link dynamically I could not...
3
by: Sven C. Koehler | last post by:
Hello, the html below displays a box (#container) with a #footer and an #image inside. Is there any way how I could get rid of declaring max-width and max-height for the #image? The #image...
4
by: SM | last post by:
Hello, I've created a Unordered list with images using the Javascript DOM, and i want to set up the width and height attributes of the image... The problem is that most images vary in size....
2
by: Atul | last post by:
I am unable to find image height and width in mozilla firefox. My code is working in IE but not in Mozilla. How can i find image width and height in mozilla? function check(sel) { if(sel != "")...
6
by: Stephan Bourdon | last post by:
Hi, Your opinion please on the following subject: Is it acceptable to set the width and height of an image in ems or percents in CSS? The advantage for me is that images will scale up or down...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.