How to keep a floating div centered on window resize

Posted by Jimbo on Stack Overflow See other posts from Stack Overflow or by Jimbo
Published on 2010-06-02T10:11:31Z Indexed on 2010/06/02 10:13 UTC
Read the original article Hit count: 191

Filed under:
|
|
|

Is there a way (without binding to the window.resize event) to force a floating DIV to re-center itself when the browser window is resized?

To help explain, I imagine the pseudocode would look something like:

div.left = 50% - (div.width / 2)
div.top = 50% - (div.height / 2)

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery