Monday, February 14, 2011

DIV vertically center align content in IE7 and IE8

Before jquery we struggled a lot to get div content vertically center in all browsers. But the wait is over; now we can have div content vertically centered with the help of a small jquery function.

Here is the Demo





2 comments:

  1. I tried your code. But a CSS solution worked:

    This fixed the problem. Knowing the height and width of the control, I used

    http://css-tricks.com/320-quick-css-trick-how-to-center-an-object-exactly-in-the-center/

    ReplyDelete
  2. @Bill Thompson
    The solution you used is good for static content. If you have dynamic website and the content keeps on changing, css-trick will not work. If you want to calculate correct center position without any static adjustments, you will find this post helpful.

    ReplyDelete