<?xml version="1.0" encoding="UTF-8"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

			>

	<channel>

		<title>Using div ID as Anchor, Navbar Header covers linked div &#8211; Themeco Community</title>
		<atom:link href="https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/feed/" rel="self" type="application/rss+xml" />
		<link>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/feed/</link>
		<description></description>
		<lastBuildDate>Sun, 12 Oct 2025 03:23:52 +0000</lastBuildDate>
		<generator>https://bbpress.org/?v=2.6.14</generator>
		<language>en-US</language>

		
														
					
				<item>
					<guid>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-48267</guid>
					<title><![CDATA[Using div ID as Anchor, Navbar Header covers linked div]]></title>
					<link>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-48267</link>
					<pubDate>Sun, 25 May 2014 17:44:53 +0000</pubDate>
					<dc:creator>Kris B</dc:creator>

					<description>
						<![CDATA[
						<p>Hi, </p>
<p>I&#8217;m trying to have a bulleted icon list at the top of a page, and each list item is a link to a different div down-page. My problem is that, at least in Chrome browser, when I jump to an ID&#8217;d div, the navbar header covers the top of that div, which may be pertinent info, like header text. </p>
<p>How can this be fixed or worked around? If there&#8217;s a way to go down to x ems above the div? Any ideas welcome!</p>
<p><a href="http://www.grellcommercialroofing.com/commercial-roofing-services/#liability" title="liability div" target="_blank" rel="nofollow">Here&#8217;s a page where I tried this, on a div ID&#8217;d &#8220;liability&#8221;.</a></p>
<p><img decoding="async" src="http://www.anonimg.com/img/d41d5292f775aa6919b0ef8e0275c0c1.png" alt="" /></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-48368</guid>
					<title><![CDATA[Reply To: Using div ID as Anchor, Navbar Header covers linked div]]></title>
					<link>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-48368</link>
					<pubDate>Mon, 26 May 2014 03:40:23 +0000</pubDate>
					<dc:creator>Rad</dc:creator>

					<description>
						<![CDATA[
						<p>Hi Kris,</p>
<p>Thank you for writing in!</p>
<p>Try adding this at your customizer&#8217;s custom javascript.</p>
<pre><code>jQuery(function($){
  $(document).ready(function(e){
    $(&#039;html,body&#039;).animate({
      scrollTop: $(&#039;#&#039; + location.href.split(&quot;#&quot;).slice(-1)[0] ).offset().top - $(&#039;.x-navbar&#039;).height()
    },700 ,&#039;swing&#039;);
  });
});</code></pre>
<p>Hope this helps.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-48381</guid>
					<title><![CDATA[Reply To: Using div ID as Anchor, Navbar Header covers linked div]]></title>
					<link>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-48381</link>
					<pubDate>Mon, 26 May 2014 04:18:20 +0000</pubDate>
					<dc:creator>Kris B</dc:creator>

					<description>
						<![CDATA[
						<p>Thank you, much better!</p>
<p>It still goes down a little past the top of the ID&#8217;d div (maybe 2ems), but much improvement. Can I play with that 700 number in the script, or is that for something else? Or do I try changing &#8220;slice(-1)&#8221; to &#8220;slice(-1.25)&#8221;? I don&#8217;t know javascript so forgive my ignorance on what the adjustments are.</p>
<p>Is this code something I could paste into the functions sheet of my child theme? I just always want to get stuff away from the customizer fields so I don&#8217;t fill them up with snippets.</p>
<p>Thanks again!</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-48488</guid>
					<title><![CDATA[Reply To: Using div ID as Anchor, Navbar Header covers linked div]]></title>
					<link>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-48488</link>
					<pubDate>Mon, 26 May 2014 13:39:03 +0000</pubDate>
					<dc:creator>Alexander</dc:creator>

					<description>
						<![CDATA[
						<p>Hi Kris,</p>
<p>I checked your page, and it looks like the scroll is perfectly moving the bottom of the navbar to the top of the div.</p>
<p>Instead of changing the navigation, I would recommend placing the <code>liability</code> ID on the custom headline element instead of the div. This will move it a bit further down the page.</p>
<p>I wouldn&#8217;t advise changing that code, because it would affect all instances of this effect we&#8217;re adding. So it you have other anchors used for navigation, it affects them too.</p>
<p>But to answer your question, and explain what&#8217;s going on in that javascript a bit.</p>
<p>This expression grabs the value of the address bar, and splits after the <code>#</code><br />
<code>location.href.split(&quot;#&quot;).slice(-1)[0]</code></p>
<p>That value is used to find the target ID&#8217;s location on the page. So based on the previous information, it simplifies to this:</p>
<p><code>$(&#039;#&#039; + anchor ).offset().top</code></p>
<p>But that leaves us with the same problem as before. We need to subtract the height of the navbar:</p>
<p><code>$(&#039;.x-navbar&#039;).height()</code></p>
<p>That finds the navbar, and returns it&#8217;s height. Then it&#8217;s subtracted from the target ID elements position, and the scroll is executed.</p>
<p>To change the scroll offset, you can add or subtract at the very end of that line. You could also change the selector for the navbar to something else. For example:<br />
<code>$(&#039;#&#039; + location.href.split(&quot;#&quot;).slice(-1)[0] ).offset().top - $(&#039;.x-navbar&#039;).height() + 40</code></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-48505</guid>
					<title><![CDATA[Reply To: Using div ID as Anchor, Navbar Header covers linked div]]></title>
					<link>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-48505</link>
					<pubDate>Mon, 26 May 2014 14:39:58 +0000</pubDate>
					<dc:creator>Kris B</dc:creator>

					<description>
						<![CDATA[
						<p>Thanks for that detailed explanation! Very helpful.</p>
<p>My navbar was still encroaching a little further down the div to almost the headline element. I haven&#8217;t checked it again yet, but I&#8217;m pretty sure I have 1em of top padding in the parent (ID&#8217;d) div, so if I went to that anchor, it would theoretically also be overshooting, right? But I did log out of WP admin to get rid of that black bar at the top, because it seemed like that was the amount it was overshooting. Maybe it is? And I should clear cache and wait for it to update as I&#8217;m logged out to check it out?</p>
<p>Again, you guys are great help, much appreciated &#8211; first time purchasing premium themes, and very satisfied.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-48810</guid>
					<title><![CDATA[Reply To: Using div ID as Anchor, Navbar Header covers linked div]]></title>
					<link>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-48810</link>
					<pubDate>Tue, 27 May 2014 13:45:17 +0000</pubDate>
					<dc:creator>Alexander</dc:creator>

					<description>
						<![CDATA[
						<p>Hi Kris,</p>
<p>Ah, that would be it. The script doesn&#8217;t take into account the additional height of the WordPress toolbar. When logged out, does it work correctly? If I check your site it looks just fine to me now that the code is in place.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-48826</guid>
					<title><![CDATA[Reply To: Using div ID as Anchor, Navbar Header covers linked div]]></title>
					<link>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-48826</link>
					<pubDate>Tue, 27 May 2014 14:35:10 +0000</pubDate>
					<dc:creator>Kris B</dc:creator>

					<description>
						<![CDATA[
						<p>I think that was it. I cleared my cache plugin and logged out and it seems to work great.</p>
<p>Thanks for that!</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-49053</guid>
					<title><![CDATA[Reply To: Using div ID as Anchor, Navbar Header covers linked div]]></title>
					<link>https://theme.co/archive/forums/topic/using-div-id-as-anchor-navbar-header-covers-linked-div/#post-49053</link>
					<pubDate>Wed, 28 May 2014 03:09:17 +0000</pubDate>
					<dc:creator>Christian</dc:creator>

					<description>
						<![CDATA[
						<p>Glad it&#8217;s working now Kris.</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

