下面是我的代码片段,我用它来将 div 从左向右移动。
https://jsfiddle.net/nf6pqbr0/1/u/
$( "#go" ).click(function() {
var stop = $(".stopdiv").offset().left;
var obj = document.getElementById("audio");
$( ".move" ).animate({
opacity: 0.25,
left: stop-($(".stopdiv").width()+$(this).width()),
}, {
duration: 1000,
step: function(){
$('.sound').each(function(){
});
}, complete: function() {
$(this).css('left',0);
$(this).css('height','100%');
}});
});
要设置元素的左侧,您应该设置它的位置relative/fixed/absolute
在您的情况下,将 .move 的位置设置为相对位置
.move{position:relative;background:green;width:2px; height:100px;}
工作示例
Another Demo你可以看一下
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)