Monday, July 30, 2012

HTML/CSS - how to vertically align a website

Let's say you have a web element and you want it to be vertically aligned on the screen. It can even be an entire website.
1. In the CSS file, set the html height property to 100%
2. Place the element you want to vertically align inside of a td tablewith the following properties: 


<table cellpadding="0" cellspacing="0" border="0"
style="height:100%;width:100%">
<tr>
<td valign="middle" align="center"
style="height:100%; width:100%">
    <form id="tentoo_form" runat="server">
    <div id="website">YOUR WEBSITE GOES HERE</div>
    </form>
    </td>
</tr>
</table>

That should do the trick.


Cheers!

No comments:

Post a Comment