Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

HTML - vertically align a table to centre of screen

Thread Tools
 
Search this Thread
 
Old 21 February 2005, 09:12 PM
  #1  
Fuchsrohre
Scooby Regular
Thread Starter
 
Fuchsrohre's Avatar
 
Join Date: Feb 2005
Posts: 567
Likes: 0
Received 0 Likes on 0 Posts
Default HTML - vertically align a table to centre of screen

Which style sheet element do you modify to verticlly align a table to the centre of the browser window ?

I know IE will accept it if you cheat like this (but its not compliant code):

<table width=100% height="*">
<tr> <td> table 1 </td> </tr>
</table>

<table width=100% height=400>
<tr> <td> table 2 </td> </tr>
</table>

<table width=100% height="*">
<tr> <td> table 3 </td> </tr>
</table>

I want a universal method which means altering the style sheet, so that it works in all compliant browsers. Which element do I change ?

eg. if I do this in a style sheet it DOESN'T WORK:

table.top {
height: 25%;
}

table.middle {
height: 50%;
}

table.bottom {
height: 25%;
}

Last edited by Fuchsrohre; 21 February 2005 at 09:58 PM.
Old 22 February 2005, 01:50 AM
  #2  
Fuchsrohre
Scooby Regular
Thread Starter
 
Fuchsrohre's Avatar
 
Join Date: Feb 2005
Posts: 567
Likes: 0
Received 0 Likes on 0 Posts
Default

ok, I've checked this out and it turns out y code is correct and the table is actually setting itself correctly - however the table is constrained by whatever setting the BODY and HTML tags have been set to.

Adding the following to the style sheet did the trick

html, body {
height: 100%;
}
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Scott@ScoobySpares
Full Cars Breaking For Spares
55
05 August 2018 07:02 AM
shorty87
Full Cars Breaking For Spares
19
22 December 2015 11:59 AM
LSherratt
Non Scooby Related
20
28 September 2015 12:04 AM
shorty87
Other Marques
0
25 September 2015 08:52 PM
shorty87
Wheels And Tyres For Sale
0
25 September 2015 08:36 PM



Quick Reply: HTML - vertically align a table to centre of screen



All times are GMT +1. The time now is 09:34 AM.