- This topic has 57 replies, 7 voices, and was last updated 6 years, 1 month ago by Michael.
-
AuthorPosts
-
July 16, 2016 at 9:57 am #210352TomLead DeveloperLead Developer
CTAs and buttons are better dealt with by plugins 🙂
August 9, 2016 at 1:30 pm #216958MarkusJust adding this to get involved in new replies.
I am also using the “Hash Link Scroll Offset Plugin”.
Would be nice, if this is part of the GP theme some day.August 9, 2016 at 1:38 pm #216959Markus@bin topic: “Hash Link Scroll Offset Plugin”
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 works fine for me. If you declare the anchor links like
<a href="#[my-hash]">
instaed of
<a href="https://[mydomain.mytld/mypage#my-hash]">
it works fine from external, internal und the same page.September 18, 2016 at 2:41 pm #227523BinHello, Tom.
I’m still struggling with the “anchor offset” in sections. Using this
<p style=”position: relative;”></p>
is causing W3C-Warnings, because the NAME-tag is obsolete. Therefore I would rather prefer this:
but the WP-Editor doesn’t accept empty links!!!
Do you have any decent solution??? Regards, Bin
PS: Are you already working on an option for custom Section Names?
September 18, 2016 at 2:44 pm #227524BinUpps, sorry for the lost code snippets above:
1.
<p style="position: relative;"><a id="test2" style="position: absolute; top: -80px;" name="test2"></a></p>
2.
<a class="anchor" id="test2"></a>
September 18, 2016 at 2:50 pm #227527BinMaybe this could be working?
<h2 class="anchor" id="test2"></h2>
with this css:
a.anchor { display: block; position: relative; top: -90px; visibility: hidden; }
September 18, 2016 at 10:28 pm #227595TomLead DeveloperLead DeveloperYou can give anything an ID, for example:
<div class="anchor" id="test"><!-- anchor --></div>
September 19, 2016 at 6:34 am #227679BinSorry, Tom. It doesn’t work!
I used
<div class="anchor" id="test"><!-- anchor --></div>
together with
a.anchor { display: block; position: relative; top: -80px; visibility: hidden; }
Result: NO scroll-offset-effect!!!
Where is my mistake?
September 19, 2016 at 6:46 am #227683BinBy the way: I use your plugin “Simple CSS” for code insertions! Bin
September 19, 2016 at 9:25 am #227738TomLead DeveloperLead DeveloperIs your link jumping to the empty div at least?
September 19, 2016 at 9:38 am #227750BinYep!
September 19, 2016 at 10:57 pm #227850TomLead DeveloperLead DeveloperI personally use this code:
<script> jQuery(function($) { $('a.smooth[href*="#"]:not([href="#"])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top - 60 }, 500); return false; } } }); }); </script>
Then give your links a class of
smooth
.The
60
in the code is the amount of pixels to offset.September 20, 2016 at 4:50 am #227937BinOK, I’ll give it a chance. But please tell me: Where is the perfect place for this code? I guess, I have to create a new plugin… ;))
September 20, 2016 at 6:25 am #227964BinWell, I tried the code in the header (wp_head) and footer (wp_footer) using your Hook-Plugin > NO effect!
September 20, 2016 at 9:56 am #228068TomLead DeveloperLead DeveloperIn wp_footer should work.
I’m using it here on this site with great success.
Have you added the
smooth
class to the links that link to specific sections? -
AuthorPosts
- You must be logged in to reply to this topic.