I am currently working on vertically centering a div called container. It was successfully centered, but now I am using jQuery to add more divs to it like so:
$("#add").on("click", function () {
$(".elements").append("<div class='element'>World</div>");
});
If you want to see the issue in action, check out this JSFiddle: http://jsfiddle.net/CDk4E/
Here's the problem I am facing:
Initially, when no divs are added, everything looks fine (the page remains vertically centered). However, as soon as new divs are added, the .element div containing "Hello" moves to the top. Ideally, I would like it to stay in its original position and just have new .element divs added to the bottom.
EDIT: Additionally, the size of the first element is constant.