I’m trying to animate the height of 5 divs on the click of a button. Although these divs do increase in size the animation causes the divs to align at the Top rather than from the bottom. If that makes any sense. I would actually prefer it to animate while coming down from the top (so aligned from the top) but even if its the other way around, this animation just completes itself then changes the divs locations.
$("button").click(function(){
$("#f").css("display", "inline");
$(".css").css("display", "inline");
$(".html").css("display", "inline");
$(".jQuery").css("display", "inline");
$(".premiere").css("display", "inline");
$(".photoshop").css("display", "inline");
$(".css").animate({height:'300'}, 600);
$(".html").animate({height:'300'}, 600);
$(".jQuery").animate({height:'125'}, 600);
$(".premiere").animate({height:'250'}, 600);
$(".photoshop").animate({height:'325'}, 600);
});
p{
transform: rotate(270deg);
margin-top: 60px;
}
#f, .css, .html, .jQuery, .premiere, .photoshop{
height: 0px;
width: 30px;
display: none;
background-color: blue;
}
.css{ background-color: blue }
.html{ background-color: red }
.jQuery{ background-color: orange }
.premiere{ background-color: purple }
.photoshop{ background-color: yellow }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<button>Go</button>
<div></div>
<div class="f">
<div class="html"><p>HTML</p></div>
<div class="css"><p>CSS</p></div>
<div class="jQuery"><p>jQuery</p></div>
<div class="premiere"><p>Premiere</p></div>
<div class="photoshop"><p>Photoshop</p></div>
</div>
2
Answers
Add
vertical-align: bottom
to.jQuery
,.html
,.premiere
,.photoshop
and.css
.Updated Fiddle
Here, for the version animating from the top down, as you would prefer it (if I understood you correct):
I also added a common class to all the bars and updated your JS and CSS a bit, to make your code a little less redundant
fiddle: http://jsfiddle.net/znxue2wg/
JS, CSS, HTML: