Click to See Complete Forum and Search --> : Dynamic positioning of layers


tobyw_1969
05-14-2003, 08:26 AM
Is there an easy way, if you are using layers, to position the whole 'page' in the centre of the browser?

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?

Anyone have a simple solution? Or do I just have to make all my webpages line up on the left of the browser?

Thanks

pyro
05-14-2003, 08:40 AM
You can do it with CSS. Something like this:

body {
text-align:center; /*Incorrect code, but necessary for buggy IE*/
}

#content {
margin: auto;
}


And then put all your content in a <div> with an id of content...

tobyw_1969
05-14-2003, 04:59 PM
Thanks pyro. I tried that, but it actually seems to put the layer off to one side... example here.

Example (http://www.netcartoon.net/hmm2.htm)

It seems to put the MARGIN right in the middle. So can I do this?

Is it possible to do something like

myWidth = 400
#content { margin:auto-(myWidth/2);}

Or something along those lines, so the layer actually sits central?

Thanks

pyro
05-14-2003, 05:03 PM
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)