开发者

JavaScript effect of moving a div region to the left/right after an click-event on an item?

开发者 https://www.devze.com 2023-03-15 11:43 出处:网络
I have a question concerning Javascript: I want to have the same effect of moving photos to the left/right 开发者_如何学编程like flickr on his page (please, compare the header on their page http://www

I have a question concerning Javascript: I want to have the same effect of moving photos to the left/right 开发者_如何学编程like flickr on his page (please, compare the header on their page http://www.flickr.com, if you click on one of the dots under the picture).

If you can show me how to do it with pure JavaScript, CSS or the JavaScript framework jQuery it would be very helpful for me!

Thanks in advance, Jonas


With jQuery you can use the animate function to animate a set of CSS properties. For example, to move an element 100 pixels to the left, taking 1000ms (1 second) to perform the animation:

$("#elementId").animate({
        marginLeft: "-=100"
    }, 1000, function() {
        //Complete
    }
);

See this fiddle for a working example.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号