You are here: Re: how to vertical align a site to the center of the screen « HTML « IT news, forums, messages
Re: how to vertical align a site to the center of the screen

Posted by cosmic foo on 08/04/05 16:25

"Eirik Eldorsen" <kunsoppel@hotmail.com> wrote in message
news:dcqfeg$gri$1@services.kq.no...
> I'm trying to vertical align and horisontal align my site to the center of
> the screen.
>
> I ended up with this code which seems to work in Opera, Firefox and IE:
> <body style="padding:0px;margin:0px;height:100%">
> <table cellpadding="0" cellspacing="0" style="height:98%;width:100%"
> border="0">
> <tr>
> <td valign="middle" align="center">
> THIS IS THE CENTER OF THE SCREEEN
> </td>
> </tr>
> </table>
> </body>
>
> However this is not valid html, because if I put:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> at the top of the page, the page is not centered any more.
>
> Is there a valid way to do this? (frames is not an option)
>
>
> Eirik
>
>

i was just working on a similar problem.
the client wants the page to be filled at 800x600,
and centered if 1024x768.
so i came up with this (which i have a feeling is not so great,
but it seems to work in ie and firefox),

<div id="abc" style="position: absolute; top: 0px; left: 0px; width:
790px;">
<script language="JavaScript" type="text/javascript">
document.getElementById("abc").style.left = (screen.availWidth -
800)/2 + "px";
</script>

..a bunch of absolute positioned divs..

</div>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация