【问题标题】:JQuery: Combining animate CSS and fadeInJQuery:结合动画 CSS 和淡入淡出
【发布时间】:2013-11-27 22:16:36
【问题描述】:

这是我的脚本:

$("#headerimage").animate({marginLeft:"0"},300);

我还想添加“淡入淡出”以同时以完全相同的速度启动。这是怎么做到的?

【问题讨论】:

    标签: jquery jquery-animate fadein


    【解决方案1】:

    通过动画不透明度:

    $("#headerimage").animate({
        marginLeft: 0,
        opacity   : 1
    }, 300);
    

    如果用 display:none 隐藏,先显示:

    $("#headerimage").css({
        opacity : 0,
        display : 'block' // or whatever
    }).animate({
        marginLeft: 0,
        opacity   : 1
    }, 300);
    

    【讨论】:

      【解决方案2】:
      $("#headerimage").animate({
          marginLeft:"0",
          opacity: 1
      },300);
      

      【讨论】:

        猜你喜欢
        • 2019-02-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-09-08
        • 2016-05-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多