Is there a way (with CSS3, JS, or anything in between) to get a page to start at a certain point scrolled down?
I'd like for my page to load without the header initially displaying on load (meaning it's above the actual viewport of the user).
Is there a simple/easy way to go about this?
HTML - Named anchors
You can also make use of good old anchors. Define a named anchor using
This should be defined at the point that has to be in view. As it can be in view even at the bottom of the screen, you might have to give anchor a little below than required. That way we will make sure that contents on top that need not be shown are well hidden. Once it is defined to scroll down when the page gets loaded, URL should be page.aspx#start instead of page.aspx
This work to me.
Thanks.
I found @bryanbraun's suggestion very useful. I found that removing the window.scroll produces a nice effect for hiding a nav bar. I've simply added this to the head of my doc:
and then added a wrapper around my nav bar and an onscroll trigger rather than an onload:
This the nice effect of not causing any interruption to the user, but when they scroll up they see the nav bar :)
It's currently in use here
These are very simple tricks for that:
Create css offset class and assign to the body
So that body will be loaded with 500px offset from top
Then add following code to the body
then using jquery, remove offset class when page is loaded
The current answers result in a noticeable "jump" down the page, or require you to know the exact pixel number you want to jump.
I wanted a solution that jumps past a container, regardless of the size/contents of the container, and here's what I came up with:
HTML
CSS
JS
Working Demo Here
The Combined Solution
Every single JavaScript-first solution may (and usually does) lead to a hiccup before the pageLoad event. As Uday suggested, the best way to achieve seamless scrolled load is to employ the negative css margin.
Personally, I use a code snippet similar to the one of Uday, however slightly tweaked to make it work in browsers without JavaScript and not to repeat the scroll declaration.
The short self-calling function in the onLoad attribute can be expanded as follows: