我试图通过单击适当的按钮来使某些项目从一个位置移动到新位置。即使我使用固定位置并使用javascript来设置动画之前的位置,但事情仍然不在页面上直到终点。

Firefox和Webkit浏览器在打开和关闭时有不同的错误,我对此没有找到可靠的解决方案,有人可以帮我解决这个问题吗?

$(function(){
    $("#nav li").click(function() {
        $("#nav").css({
            'left' : $(this).position().left + 'px',
            'top' : $(this).position().top + 'px'
        })
        .animate({
             'margin-top' : '-175px',
              'margin-left' : '0px',
            'left' : '10px',
            'top' : '50%',
            'height' : '370px',
            'width' : '70px'
        }, 500, 'swing');

        $("#name").css({
            'top': $(this).position().top + 'px'
        })
        .animate({
            'top' : '100px'
        } , 500, 'swing');
    });

    $("#buttona").click(function() {
        $("#a").animate({
            'opacity' : '1' ,
            'top' : '50%',
             'margin-top' : '-200px'
            }, 500, 'swing');
    });

});


http://coreytegeler.com/jg/

最佳答案

您使用#nav li#a.set#a感到担心。 ID必须是唯一的,因此在选择器中仅使用ID永远是没有道理的。几乎可以肯定这是动画问题的原因。

关于javascript - Javascript动画,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18263582/

10-11 03:01
查看更多