Tables with 100% width and height

This is a discussion on "Tables with 100% width and height" within the Web Page Design section. This forum, and the thread "Tables with 100% width and height are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 4th, 2008, 05:32
Junior Member
Join Date: Feb 2008
Location: Melbourne
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Tables with 100% width and height

When making HTML I enjoy making tables that are 100% width and height, cos then I can set the single cell (only one column and only one row) to be middle and centred. This way I can put stuff in the dead centre of the page.

Recently I can't seem to get the height to stay at 100%. I just don't get it. I use Dreamweaver, and I've been doing the exact same thing for years, but with the version of DW I'm using now, it just doesn't seem to work (for the height only).

Has anyone else had this sort of experience or know a solution?

Ta.
Reply With Quote

  #2 (permalink)  
Old Feb 4th, 2008, 05:58
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Tables with 100% width and height

Well, you should consider using DIV (CSS) instead of the old way which is TABLE
Your browser loads pages with CSS codes much more faster than pages that have table elements inside it! In other words its slow down your HTML rendering process.

So... Here is how you do it in CSS:
First, paste this CSS style in your <head> section of your HTML page.
HTML: Select all
<style type="text/css">
        body {
            margin: 0;
            padding: 0;
        }
        
        div#container {
            margin: 5px auto; /*This is how you center your page*/
            width: 90%;
            border: 1px solid #000;
            padding: 5px;
            background-color: #ddd;
        }
</style>
And then, put this DIV in your <body> section of your HTML page.
HTML: Select all
<body>
<div id="container">
    <h1>Centered Div - Throw all your cool stuff here!</h1>
    <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
</div>
</body>
EDIT:
Forgot to include the link here!
and some of our very own tutorial in the CSS forum sticky here!
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)

Last edited by Monie; Feb 4th, 2008 at 06:05.
Reply With Quote
  #3 (permalink)  
Old Feb 4th, 2008, 06:00
saltedm8's Avatar
Lead Administrator

SuperMember
Join Date: Nov 2005
Location: Always About
Age: 27
Posts: 1,511
Blog Entries: 1
Thanks: 1
Thanked 11 Times in 11 Posts
Re: Tables with 100% width and height

sorry, but there is only one answer, learn css ( as stated above ), start here http://www.cssbasics.com/ , any questions and we are on hand to help
Last Blog Entry: Basic Advice for newbies (Feb 1st, 2008)
Reply With Quote
  #4 (permalink)  
Old Feb 5th, 2008, 03:10
Junior Member
Join Date: Feb 2008
Location: Melbourne
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Tables with 100% width and height

Can I modify this code to change or at least add a height value (100%)? Because that's more what I'm really after. Making my table the full length (height) of the browser page / window.

Cos I'm trying to not just centre the page horizontally, but also vertically.

I guess not... I just tried it. : /

I just read thru Chapter 15 (CSS Width and Height) from http://www.cssbasics.com/, and tried the height, min-height, and max-height values, but none worked. Can someone suggest what I might be doing wrong?

Last edited by Griff; Feb 5th, 2008 at 04:00.
Reply With Quote
  #5 (permalink)  
Old Feb 5th, 2008, 04:02
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Tables with 100% width and height

Yes you can! Gimme your current HTML and CSS and I'll see what I can do
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #6 (permalink)  
Old Feb 5th, 2008, 04:06
Junior Member
Join Date: Feb 2008
Location: Melbourne
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Tables with 100% width and height

Could it be that the item I want to be 100% in height needs to be IN something with a value so it knows what 100% actually is?

Would you like my entire HTML and CSS code? They're rather lengthy!

Last edited by Griff; Feb 5th, 2008 at 04:41.
Reply With Quote
  #7 (permalink)  
Old Feb 5th, 2008, 04:46
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Tables with 100% width and height

Do you host it somewhere?
Well, if you want to center them horizontally, you just need to change one line of code in the CSS that I gave you earlier

Code: Select all
#container {
 margin: 0 auto; /*This is how you center your page Horizontally*/
 width: 90%;
 border: 1px solid #000;
 padding: 5px;
 background-color: #ddd;
}

or using the absolute positioning like this:
Code: Select all
#container {
 margin: 0;
 padding: 5px;
 position: absolute;
 top: 0;
 right: 10%;
 width: 80%;
 border: 1px solid #000;
 background-color: #ddd;
}
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #8 (permalink)  
Old Feb 5th, 2008, 04:52
Junior Member
Join Date: Feb 2008
Location: Melbourne
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Tables with 100% width and height

Yup, you can see the website hosted here:

http://griffdesign.com/websites/lc/content/home.html

The CSS file (lightcycle.css) is in the same folder.

I tried adding "height: 100%;" to the code, but it didn't seem to make a difference...

I want to centre both Horizontally AND Vertically. I've got the horizontal working, but not the vertical. As you will see on that link, the design layout ought to extend to the bottom of the browser window.

Last edited by Griff; Feb 5th, 2008 at 04:58.
Reply With Quote
  #9 (permalink)  
Old Feb 5th, 2008, 05:08
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Tables with 100% width and height

Well I must say that you should not use table if you want to learn CSS. You use CSS for your page layout and just use table for tabular data like displaying data from your database stuff

By the way here is the trick:
HTML: Select all
        #Container {
            margin: 0;
            position: absolute;
            top: 0;
            bottom: 0;
            right: 20%; /*play around with this value to center your page*/
            width: 60%;    /*play around with this value to center your page*/        
            padding: 0px;
            border: 1px solid red;
        }
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #10 (permalink)  
Old Feb 5th, 2008, 06:05
Junior Member
Join Date: Feb 2008
Location: Melbourne
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Tables with 100% width and height

I just realised I may have been leading you astray... I'm very tired, sorry!

What I'm actually after is making the table reach the bottom of the browser window. Usually, and in the past I've been able to make a table 100% in height and it'd stretch all the way from the top of the window to the bottom. Centering is more of what I do after I've stretched the table out.
Reply With Quote
  #11 (permalink)  
Old Feb 5th, 2008, 06:10
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Tables with 100% width and height

Ohh, LOL. It's ok tho...
I haven't play around with table for quiet sometime and in fact I rarely use table for my layout
CSS is the best way for lay outing our page. You might want to check that out!
Cheers...
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #12 (permalink)  
Old Feb 5th, 2008, 07:03
Junior Member
Join Date: Feb 2008
Location: Melbourne
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Tables with 100% width and height

Yeah, while searchign the web I noticed a lot of people seem to bag tables and rave about CSS. While I do know how to use CSS, and I have been using it for a few years now, I can't understand how it could be better than tables for layouts, but I guess that's another subject altogether.

Anyways, here's the site now, as it was meant to be.

http://griffdesign.com/websites/lc/content/home.html

I finally figured it out. It wasn't an HTML or CSS problem! Stupid Dreamweaver had code at the top of the page that I realised many of the websites I've designed in the past never had... Protocols and what not... This stuff:

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

I know that stuff is important, but it's screwing with my design...

Last edited by Griff; Feb 5th, 2008 at 07:08.
Reply With Quote
  #13 (permalink)  
Old Feb 5th, 2008, 07:14
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Tables with 100% width and height

It's a HTML doctype. You should use a strict doctype or you could choose from here!
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #14 (permalink)  
Old Feb 5th, 2008, 07:22
Junior Member
Join Date: Feb 2008
Location: Melbourne
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Tables with 100% width and height

Thanks! : )
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS Box of auto width and height? Bolt Web Page Design 2 Apr 14th, 2008 08:20
floating a div across the whole width and height of a table cell cosmicbdog Web Page Design 3 Feb 1st, 2008 14:26
Pictures disappearing with correct width and height! ChrisTheSoul Web Page Design 3 Sep 3rd, 2007 21:56
Borders made from graphics, but fluid width and height wickedmoon Web Page Design 1 Aug 17th, 2007 11:20
Trouble with form controls. Height, width and all that magnetica Web Page Design 7 Aug 10th, 2007 12:47


All times are GMT. The time now is 20:46.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43