Garbage Burrito!

An internet web blog by Ben Kittrell

Center Elements Horizontally and Vertically with Prototype

Center Elements Horizontally and Vertically with Prototype
Ben Kittrell - 10/17/2010 00:27:00
Comments: 3
Wanted to share this little snippet that lets you easily center Elements vertically and horizontally in the viewport.

Once you add the code you can call it like so...

$('my_div').centerVertically();
$('my_div').centerHorizontally();

The code is paste below and also on Gist.


Comments: 3

Comments

1. rheaghen   |   10/17/2010 17:58:55

this utility could also capture elements passing through and add them to an interval that provides dynamic resizing when the dom mutates... allot easier than stubbing in a buch or overly complex event functions everywhere.

2. Ben   |   10/18/2010 12:21:48

That's why I put it on Gist :) Be my guest.

3. auto scanner  |  my website   |   04/07/2011 09:31:56

this utility could also capture elements passing through and add them to an interval that provides dynamic resizing when the dom mutates... allot easier than stubbing in a buch or overly complex event functions everywhere.

Post a Comment


Please enter the word below.


powered by Doodlekit™ Free Website Builder by Doodlebit™ Website Company