jquery + css scroll above div

I'm following this forum for a longer time. But because I didn't find an answer, I've registered to ask a question.

So my HTML structure is following:

<div id="nav">
...<!-- navigation #1 !-->
</div>

<div id="nav2">
<li><a id="jan" href="#januar">JANUAR</a></li>
etc..
<!-- navigation #1 !-->
</div>


<div id="content">
<div id="januar">
*header here*
*table here*
</div>
<!-- februar, etc...-->
</div>

Now what I want is. When clicking the #jan link, navigate the #januar to the middle of the screen, however DON'T scroll OVER the nav and nav2. I've tried many css and jquery tricks. But none work. I also didn't found any theme with such criterias. Any suggestions?

Problem courtesy of: pbalazek

Solution

Here is the script adjust top value to 50%.. to make it middle

$('html,body').animate({
                    scrollTop: $('#januar').first().offset().top - 100
                }, 'slow');

Solution courtesy of: Velmurugan

我来评几句
登录后评论

已发表评论数()

相关站点

+订阅
热门文章