【发布时间】:2014-10-23 02:04:23
【问题描述】:
我正在尝试通过单击按钮为 5 个 div 的高度设置动画。尽管这些 div 的大小确实会增加,但动画会导致 div 在顶部而不是从底部对齐。如果那有意义的话。 实际上我更希望它在从顶部向下移动时进行动画处理(因此从顶部对齐),但即使反过来,这个动画也会自行完成,然后更改 div 的位置。
$("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>
【问题讨论】:
标签: javascript jquery html jquery-animate height