[英]Expand and Animate Div Vertically and Horizontally
I'm trying to make it so that the divs within my carousel slider will toggle and expand into a larger div that will fit within the carousel on-click and reset with new div contents. 我正在尝试使轮播滑块中的div切换并扩展为更大的div,该div会在单击时轮播内并用新的div内容重置。 All the expanding divs I've looked at have only slid down, and the old div information remains.
我看过的所有扩展div都只滑下来,并且旧的div信息仍然保留。
This is the only JavaScript I've found, but I do not know how to apply it with new div information upon expanding. 这是我找到的唯一JavaScript,但是在扩展时,我不知道如何在新的div信息中应用它。
$("#expand").click(function(){
$(".article-container").animate({
width: "100px",
height: "100px",
top: "-50px",
left: "-50px",
opacity: 0.6,
}, 1500 );
});
Here is the CSS for the container before expanding and after. 这是容器在展开之前和之后的CSS。
.article-container{
float: left;
width: 193px;
height: 360px;
margin: 0 13px 0 0;
}
.article-container-expand{
float: left;
width: 500px;
height: 1000px;
margin: 0 13px 0 0;
}
If you want to apply data changes after the animation then you need to specify a completion callback for the animate call: 如果要在动画之后应用数据更改,则需要为动画调用指定完成回调:
$("#expand").click(function(){
$(".article-container").animate({
width: "100px",
height: "100px",
top: "-50px",
left: "-50px",
opacity: 0.6,
},
{ duration: 1500,
complete: function() {
// update the content here
// this is the item being animated
}
}
);
});
See the jQuery animate documentation 请参阅jQuery动画文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.