How to make page move down?

Soldato
Joined
31 May 2006
Posts
4,239
Location
127.0.0.1
Sorry for the naff subject... here is my attempt at describing what i'm after:

After playing with AJAX (and jQuery) I want to make a page that smoothly moves down to make room for a new item at the top... a bit like how facebook does when you get a friends new status update or like on a BBC sport page when a live event is on (e.g. evening football).

I'm guessing it is a mixture of javascript and CSS. Has anyone got any good links with any examples?
 
Sure there's a more contact way of doing it, but I've always used this. Will smooth scroll all your anchor links.

Code:
$('a[href*=#]').each(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname && this.hash.replace(/#/,'') ) {
            var $targetId = $(this.hash), $targetAnchor = $('[name=' + this.hash.slice(1) +']');
            var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
            
            if ($target) {
                var targetOffset = $target.offset().top;
                $(this).click(function() {
                    $('html, body').animate({scrollTop: targetOffset}, 600);
                    return false;
                });
            }
        }
    });
 
Back
Top Bottom