Archived topic
Offset anchors with fixed header
57 replies · Started by theonetruevlad on January 29, 2015
<p style="position: relative;"></p>
Hi Tom,
The above works beautifully. I found it here - http://stackoverflow.com/questions/17534661/make-anchor-link-go-some-pixels-above-where-its-linked-to
after completely not being able to work out where to put the
a.anchor {
display: block;
position: relative;
top: -250px;
visibility: hidden;
}
Happy.
<p style="position: relative;"><a id="economics" style="position: absolute; top: -100px;" name="economics"></a></p>
Happier now I finally figured that bit out as well.
Awesome :)
Thanks for your perseverance Tom, I appreciate it. I'm enjoying playing in GeneratePress.
Cheers.
No problem! Glad you're enjoying it :)
Hi. Wouldn't this plugin the easier way to solve the problem (until Tom integrates his own solution! ;))
https://wordpress.org/plugins/hash-link-scroll-offset/
Cheers, Bin
Cool plugin, thanks for sharing! :)
Yes, but unfortunately NOT perfect as i found out last night. If you click an anchor link (absolute link!) from the actual/same page (e.g. a top menu button) it does not work properly. It's really a pity! The very best option would be: YOU (Dear Tom) integrate a plugin that fits perfectly into GP!!! Maybe there is one on the way already???
Bye, Bin
I'll try to get this integrated into the next version, but it might not be until 1.2.89.
OK, sounds good.
By the way, you solved the problem by using the section-ID for the INSTALL-Button on your page:
https://generatepress.com/install-generatepress/
But the url ".../#generate-section-2" is not soooo good for SEO! ;)
Is there a way to rename/customize the Section-Name?
I'm afraid not, but you can add an anchor into your section content and link to it:
<a name="my-seo-friendly-id"><!-- anchor --></a>
Sections is currently being re-written so I'll see if I can add a new field in there for users to specify a custom ID :)
Wow, that would be great! Thanks, Bin
AND a Section-CTA-Button-Field would even be greater! ;))