CSS only and link binding solution
With pseudo-element :
First:
set: html,body{height:100%;}
The second:
Select one of the existing tags. This tag should not have a relatively positioned parent (except for the body tag). Preferably, the first markup element is displayed after the logo. For your example, this will be the h1 tag. And give it this CSS:
h1:before { content:""; position:absolute; height:100%; width:1px; }
This creates the element as height, as the area of ββthe viewport. Since it is displayed below the logo, the vertical scroll length matches the height of the logo.
Thirdly:
Give the first element after the id logo (for this example, I gave id="anchor" ).
Then you can use a link like this your_page_link#anchor and automatically go to the anchor (logo outside / above the viewport).
This works regardless of the height of the logo.
link to editable script
Full code:
HTML
<img src="http://blog.stackoverflow.com/wp-content/uploads/StackExchangeLogo1.png"> <h1 id="anchor">Foo Bar</h1> <p>ABC12345</p> <a href="#anchor">Anchor link</a>
CSS
html, body { height:100%; margin:0; padding:0; } h1:before { content:""; position:absolute; width:1px; left:0; height:100%; }
source share