I have a div that’s positioned absolutely relative to the body. I want it to stay a certain distance from the top. How would I accomplish that?
Here are two variables I have now to keep it in the center on page load. First I grab the window height, and then I divide it by 2 and subtract half the div height. That centers it.
Code:
var = $windowHeight = $(window).height();
$navHeight = $windowHeight/2-122;
That’s all fine and dandy and I can live with that, its fixed so its still in place even while scrolling. The problem is that this is static. Meaning if they re-size the window to any dimension that’s different then it was when the page loads, it now isn’t in the middle anymore. Any ideas?