0

I'm trying to reveal a page from a specific point in this case the (div:content) further down the page.

Desired effect will have the red block at the top, however scrolling down will reveal the blue block above

UPDATED: http://jsfiddle.net/cr8uj/1/

HTML

<div class="block">
    block
</div>

<div class="content">
    content
</div>

CSS

body {
    margin: 0px;
    padding: 0px;
}
.block {
    background: blue;
    height: 300px;
    width: 100%;
    position: fixed;
}

.content {
        background: red;
        margin-top: 300px;
        top: 0;
        width: 100%;
        height: 100%;
        z-index: 100;
        position: absolute;
}
Rob
  • 1,259
  • 5
  • 26
  • 55

1 Answers1

0

You are looking for: scrollTop

http://api.jquery.com/scrollTop/

Set the current vertical position of the scroll bar for each of the set of matched elements.

Example: $('body').scrollTo('#YourDiv');

There is a question related to this: jQuery scroll to element


A good library: http://mmenu.frebsite.nl/examples/responsive/index.html

Other options:

What you need is the JavaScript window.scrollTo method

window.scrollTo(xpos,ypos)

Insert the div position in there.

Or use the JQuery method ScrollTo, see an example here

$(...).scrollTo( 'div:eq(YourDiv)', 800 );
Community
  • 1
  • 1