Javascript 将位置移动到绝对图像 $(“#平面”)。设置动画({ “不透明度”:0.8 “左边距”:0 }衰减(“慢”); img/plane.png“alt=”“/> .LogoBG.飞机{ 浮动:右;左边距:666px;位置:绝对; }
我想将对象从左边距:666移动到0。另外,我想在“在”的左边距属性小于333时淡出图像。如果可能的话 谢谢试试这个:Javascript 将位置移动到绝对图像 $(“#平面”)。设置动画({ “不透明度”:0.8 “左边距”:0 }衰减(“慢”); img/plane.png“alt=”“/> .LogoBG.飞机{ 浮动:右;左边距:666px;位置:绝对; },javascript,jquery,animation,Javascript,Jquery,Animation,我想将对象从左边距:666移动到0。另外,我想在“在”的左边距属性小于333时淡出图像。如果可能的话 谢谢试试这个: $("#plane").animate({ "opacity" : 0.8 "margin-left" : 0 },10000).fadeOut('slow'); <div class="LogoBG"> <span class="plane" id="plane"> <img src="<
$("#plane").animate({
"opacity" : 0.8
"margin-left" : 0
},10000).fadeOut('slow');
<div class="LogoBG">
<span class="plane" id="plane">
<img src="<?php echo ROOTPATH ?>img/plane.png" alt="" />
</span>
</div>
.LogoBG .plane {
float:right; margin-left:666px;position:absolute;
}
这里有一把小提琴来测试它:这个怎么样:
$("#plane").animate(
{"margin-left": 333},
5000,
'linear',
function(){
$(this).animate(
{"opacity": 0, "margin-left": 0},
5000,
'linear'
);
}
);
肯定比我的更流畅。@StefanoP:没问题-你的真的更干净!:)@WebDeveloper:只是有一个小故障使它失效了。你必须在两个动画中用“左边距”替换“左边距”。我已经发布了一个编辑,应该很快得到批准。这里是提琴:
$(document).ready(function() {
$("#plane").animate({'margin-left': 333}, 1000, 'linear')
.animate({'margin-left': 0, 'opacity':0}, 1000, 'linear');
});