我有一个色 block ,每次我按下它时我都希望它缩小。
$('#blue').click(function(){
$(this).animate({width: '90%'},1000);
});
但它是从右侧走的。如何让它向左侧缩小?
CSS:
#blue{
height:250px;
width:500px;
background-color:blue;
}
html:
<div id='blue'></div>
最佳答案
您可以float: right
父级中的#blue
元素(如果需要,您可能希望在其上应用某种 float 清除)。
或者只是将 position:absolute
和 right : 0;
分配给 #blue
元素,位于具有 position:relative 的父元素内;
关于jQuery 为元素的左侧设置动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11292412/