Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将位置移动到绝对图像 $(“#平面”)。设置动画({ “不透明度”:0.8 “左边距”:0 }衰减(“慢”); img/plane.png“alt=”“/> .LogoBG.飞机{ 浮动:右;左边距:666px;位置:绝对; }_Javascript_Jquery_Animation - Fatal编程技术网

Javascript 将位置移动到绝对图像 $(“#平面”)。设置动画({ “不透明度”:0.8 “左边距”:0 }衰减(“慢”); img/plane.png“alt=”“/> .LogoBG.飞机{ 浮动:右;左边距:666px;位置:绝对; }

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="<

我想将对象从左边距:666移动到0。另外,我想在“在”的左边距属性小于333时淡出图像。如果可能的话

谢谢

试试这个:

$("#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');
});