2

I have found a few techniques used for vertically aligning a DIV on the page, most of them outlined here:

http://blog.themeforest.net/tutorials/vertical-centering-with-css/

But, the project I'm working on now heavily uses Javascript on a DIV aligned in the vertical center of a page. Does anyone know a method (preferably not Javascript based) to keep the DIV vertically aligned in the center of the screen even when it's height changes via Javascript?

And also with a height: auto property if possible, so it changes with my content.

Thanks.

4

2 に答える 2

3

この CSS のみのソリューションを試してみてください。

于 2010-01-07T21:54:28.907 に答える
-1

これはテストされていませんが、試してください。

margin-top: auto;
margin-bottom: auto;
于 2010-01-07T21:36:44.557 に答える