Welcome to WebmasterWorld Guest from 54.145.246.183

Forum Moderators: not2easy

CSS Table height 100% width 100%

How do I center the content horizontally and vertically?

   
8:58 am on Feb 19, 2007 (gmt 0)

5+ Year Member



I need to make the css properties for a table with the following standard html properties:
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle><img src="logo.gif" width="567" height="379" border="0" align="middle"></td>
</tr>
</table>
Thanks for any assistance!
4:11 pm on Feb 20, 2007 (gmt 0)

10+ Year Member



You can do this tableless. Try something like this :

<body style="width : 100%; height : 100%; margin : 0; padding : 0;">
<img src="logo.gif" width="567" height="379" alt="This is my LOGO!" border="0" style="width : 567px; height : 379px; margin-top : -190px; margin-left : -284px; position : absolute; top : 50%; left : 50%;">
</body>

did not test this but should work imho.

[edited by: Moby_Dim at 4:14 pm (utc) on Feb. 20, 2007]

[edited by: SuzyUK at 4:35 pm (utc) on Feb. 20, 2007]
[edit reason] removed smiley from code [/edit]

4:12 pm on Feb 20, 2007 (gmt 0)

10+ Year Member



and Welcome to WebmasterWorld ;)
4:35 pm on Feb 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I tested it with the following, and it works on every browser except Mac IE.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Test</title>
<style type="text/css">
/* <![CDATA[ */
body
{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}

div.centerer
{
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}

img.centered
{
margin: 0;
padding: 0;
width: 320px;
height: 155px;
margin-left: -160px;
margin-top: -77px;
position: absolute;
top: 50%;
left: 50%;
}
/* ]]> */
</style>
</head>
<body>
<div class="centerer">
<img class="centered" src="images/DSC_1200.JPG" />
</div>
</body>
</html>

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month