0

http://tententen.in/として div のアニメーションを作成しています。

$(document).ready(function(){
    $('#home-top').click(function() {
        $('#top').animate({
            marginTop: '50px'
        },500);
    });
    $('#home-right').click(function() {
        $('#left').animate({
            marginLeft: '-100%'
        },'fast');
        $('#right').animate({
            marginRight: '33%'
        },'fast');
    });
    $('#home-left').click(function() {
        $('#left').css({'position':'relative'}).animate({ left:'33%' },'fast');
        $('#home-container').css({ 'position': 'relative'}).animate({ left:'33%' },'fast');
        $('#right').css({'position':'relative'}).animate({ right:'-33%' },'fast');
    });
});

私のスクリプトでは、ここには 3 つの div しかありません。左右のアニメーションだけが必要です..試してみましたが、何かが間違っています..

http://jsbin.com/amimih/1/

4

1 に答える 1

0

左の代わりにこのコードを使用できます

var pos = $(this).position();
"margin-left" : pos.left or etc;
or
left : pos.left or etc;

marginRight の代わりにこのコードを使用します

"margin-right":"30px"

または、css ファイルで position:relative を使用できます

于 2012-10-13T08:36:59.120 に答える