I want to insert a new div each time a new user is found in my database. I have the following code working if I change the CSS (remove “bottom” and “absolute” from the classes). The problem is that it starts at the top and each div is inserted below the previous one. I would like for the divs to be in the bottom left hand corner of the screen, and then move up when a new div is inserted. It would essentially push the existing divs up and the newest div would be at the bottom of the stack. Any ideas on how to do this? Any help would be appreciated. Thanks!
This code will insert a new div, but it just places it on top of the previous one.
.greyBox {
padding:8px;
background: grey;
margin-bottom:8px;
width:200px;
height:50px;
bottom:0;
position:absolute;
}
.redBox {
padding:8px;
background: red;
margin-bottom:8px;
width:200px;
height:25px;
bottom:1;
position:absolute;
}
<p>
<button id="after">New User</button>
<button id="reset">reset</button>
</p>
<div class="greyBox">Users</div>
$("#after").click(function () {
$('.greyBox').after("<div class='redBox'>User 1</div>");
});
$("#reset").click(function () {
location.reload();
});
Add a new div container with class “bottom”
http://jsfiddle.net/4np4q/