jquery - 无法在留有边距的情况下为我的 div 设置动画

标签 jquery css jquery-animate margin-left

我想要一个动画,用一个计时器滚动我的 div 并留有边距,但我什至不能有一个合适的动画,当我在我的网站上尝试时,它只是立即获得“-margin”并继续测试什么都没有。当我复制/粘贴工作代码时甚至无法获得动画。我不明白。这是我的代码:

HTML:

<div id="twitter">
  <img style="width:50px;height:50px;" src="mypicture">
  <img id="next_tweet" src="mypicture">
  <img id="next_tweet" src="mypicture">

</div>
<script src="http://code.jquery.com/jquery-1.9.0rc1.js"></script>

CSS:

#twitter {
  width: 1000%;
  padding: 95px 0 0 400px;
  margin-left: 0px;
  height: 220px;
  -webkit-transition-delay: 2s;
  /* Safari */
  transition-delay: 2s;
}

#next_tweet {
  margin-left: 65px;
  width: 50px;
  height: 50px;
}

JavaScript:

jQuery(document).ready(

  function(){
            jQuery('#twitter').animate({
                marginLeft : "-1060px"
            },1000);

});

https://jsfiddle.net/sqs7btcx/1/

[只希望我的 div 从右到左,如果可能的话全部 5 秒]

如果有人可以帮助我,谢谢

最佳答案

使用 js 库:https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
jQuery(document).ready(

  function(){
            jQuery('#twitter').animate({
                marginLeft : "-1060px"
            },1000);

});
</script>

关于jquery - 无法在留有边距的情况下为我的 div 设置动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40127956/

相关文章:

Jquery,防止排队动画

javascript - 使用 jQuery 获取链接的属性并将其作为表单发布到另一个脚本文件

javascript - Highcharts 捕获选择

javascript - 如果一个 div 的高度与另一个 div 的高度相等,请执行某项操作 - 在循环中?

css - 如何从未知的动态高度垂直居中 div?

javascript - jQuery Animate 不适用于背景颜色属性

javascript - 单击链接时使用 AJAX 替换内容

javascript - Chrome - 如果 jquery-simple-combobox 在模式内,则鼠标拖动时会折叠

javascript - 获取当前div并添加html

css - 使用 AngularJS 动画动态高度