Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h3>Description</h3> <p>You can use jQuery <code>.offset()</code> and <code>.scrollTop()</code> function</p> <h2>Update after a discussion with tguidon</h2> <p>I don't know how your <code>top-floating-bar</code> css is defined, but i know what you want. The size of the menubar in the fiddle is not right, because i dont know your definition.</p> <h3>Check out the <a href="http://jsfiddle.net/b6LBR/7/" rel="noreferrer">jSFiddle</a>.</h3> <h3>Sample</h3> <p><strong>Html</strong></p> <pre><code>&lt;head&gt; &lt;script src="jquery-1.5.1.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt;&lt; $(function() { $(".goto").click(function() { var target = $(this).attr("href") target = target.substring(1,target.length); $(window).scrollTop($('a[name="'+target+'"]').offset().top - 35); return false; }); }); &lt;/script&gt; &lt;/head&gt; &lt;div id="top-floating-bar"&gt; &lt;!-- Menubar --&gt; &lt;div class="row"&gt; &lt;div class="column grid_12"&gt; &lt;div class="fixed-bar-buttons"&gt; &lt;ul&gt; &lt;a href="#top" class="goto"&gt;&lt;li&gt;Home&lt;/li&gt;&lt;/a&gt; &lt;a href="#links" class="goto"&gt;&lt;li&gt;Links&lt;/li&gt;&lt;/a&gt; &lt;a href="#resume" class="goto"&gt;&lt;li&gt;Resume&lt;/li&gt;&lt;/a&gt; &lt;a href="#social" class="goto"&gt;&lt;li&gt;Social&lt;/li&gt;&lt;/a&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- End the Menubar --&gt; &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;a name="top"/&gt; Top Section &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;a name="links"/&gt; Links Section &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;a name="resume"/&gt; Resume Section &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;a name="social"/&gt; Social Section &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; </code></pre> <h3>More Information</h3> <ul> <li><a href="http://api.jquery.com/scrollTop/" rel="noreferrer">jQuery.scrollTop()</a></li> <li><a href="http://api.jquery.com/offset/" rel="noreferrer">jQuery.offset()</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload