Dynamic positioning of layers

liunx

Guest
Is there an easy way, if you are using layers, to position the whole 'page' in the centre of the browser?<br />
<br />
I used to use tables before coming to this forum, and I like pages which centre themselves when they are smaller than the browser - I know you can use absolute positioning, so is there an easy way to determine the width of the browser, and how would you use a variable like browserWidth/2 in the specifications for your layers?<br />
<br />
Anyone have a simple solution? Or do I just have to make all my webpages line up on the left of the browser?<br />
<br />
Thanks<!--content-->You can do it with CSS. Something like this:<br />
<br />
body {<br />
text-align:center; /*Incorrect code, but necessary for buggy IE*/<br />
}<br />
<br />
#content {<br />
margin: auto;<br />
}<br />
<br />
<br />
And then put all your content in a <div> with an id of content...<!--content-->Thanks pyro. I tried that, but it actually seems to put the layer off to one side... example here.<br />
<br />
Example (<!-- m --><a class="postlink" href="http://www.netcartoon.net/hmm2.htm">http://www.netcartoon.net/hmm2.htm</a><!-- m -->) <br />
<br />
It seems to put the MARGIN right in the middle. So can I do this?<br />
<br />
Is it possible to do something like <br />
<br />
myWidth = 400<br />
#content { margin:auto-(myWidth/2);}<br />
<br />
Or something along those lines, so the layer actually sits central?<br />
<br />
Thanks<!--content-->If you remove position:absolute from your style, it should work fine... And no, CSS is not a scripting language, so you can not do thing like auto-(myWidth/2)<!--content-->
 
Back
Top