Here is my code, but it doesn't work (the div always floats to the top of the page. I want it to be located in the center of the page).
HTML:
<div id="overlay">Stuff</div>
JQuery:
$(document).ready(function(){
var height = $('#overlay').height();
var marginTop = (height)/2;
document.getElementById("overlay").style.marginTop="-"+marginTop+"px";
document.getElementById("overlay").style.top="50%";
});
What am I doing wrong?