Jessy Jordan
Jessy Jordan

Reputation: 79

Slide in a div from bottom of the page?

I am trying to the achieve an affect like the one on this page:

Slide Up/Down DIV from bottom center of the page using jquery

but I need it to work on page load with 5-6 seconds delay!

can this be done only with CSS or pure javascript? if so, how?

Thanks

Upvotes: 0

Views: 2724

Answers (1)

Michael Unterthurner
Michael Unterthurner

Reputation: 941

JQUERY:

use it with the window.onload = function ...

setTimeout(function() {
    var top = $('#yourID').position().top;
    document.getElementById('youridhere').scrollIntoView();

}, 5000); // your timeout in ms

JAVASCRIPT

old question, but if anyone finds this through google (as I did) and who does not want to use anchors or jquery there's a builtin javascript function to 'jump' to an element.

document.getElementById('youridhere').scrollIntoView();

and what's even better, according to the great compatibility-tables on quirksmode, this is supported by all major browsers!

OR You can use an anchor to "focus" the div. I.e:

<div id="myDiv"></div>

and then use the following javascript:

// the next line is required to work around a bug in WebKit (Chrome / Safari)
location.href = "#";
location.href = "#myDiv";

And else look at this fiddle :) there is a javascript only scroll animation

http://jsfiddle.net/ySeWk/

Upvotes: 3

Related Questions