Site logo

[Resolved] Anchor in menu 40px (?) too far down

Home Forums Support [Resolved] Anchor in menu 40px (?) too far down

Home Forums Support Anchor in menu 40px (?) too far down

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #2597496
    Torsten

    Hi,
    how can I adjust the anchor so that e.a. menu point “Referenzen” is reached a few pixel up, for the moment I have a white space above the “Referenzen”-section and the header on all display sizes…
    thx ahead,
    Torsten.

    #2597546
    Fernando
    Customer Support

    Hi Torsten,

    Try setting the Anchor id to this text instead “Designberatung” which is right below “Referenzen”.

    #2598275
    Torsten

    Hi Fernando,
    all anchors are “misplaced” by about the same amount. And as I’m using different widgets and display options (toggle visibility) for desktop, tablet and/or mobile I had an issue with the slide-out menu not working except for desktop previously.
    Therefore I need a code to set an offset for all anchors the same amount.
    best,
    Torsten

    #2598791
    Fernando
    Customer Support

    Can you try adding this through a Hook Element:

    <script>
    jQuery(function($) {
    	$('li.smooth-scroll > a[href*="#"]:not([href="#"]), a.smooth[href*="#"]:not([href="#"])').on( 'click', function(e) {
                    e.preventDefault();
    		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 + 100
    				}, 500);
    			}
    		}
    	});
    });
    </script>

    Hook it to wp_footer.

    #2599075
    Torsten

    Hi Fernando,
    I added the code, see screenshot-link in private information.
    No changes, I tried as well changing the values…
    best,
    Torsten

    #2599304
    Torsten

    Hi,
    I added a screenshot in private information with 6 Menu items (I wrote each menu item beside the burger menu in red) and marked the offset in each with 2 red lines, like this it is obvious that it’s the same offset for each widget / section.
    best,
    Torsten

    #2599493
    David
    Staff
    Customer Support

    Hi there,

    that looks real tricky, the only way i would think you could make that work consistently is if the page was split into sections and each section had the anchor attached to it.

    you would also need to make sure the site header was a constant height.

    That way you have consistency for the anchor positioning.

    #2599849
    Torsten

    was worth the try.
    Thx for the effort,
    best,
    Torsten

    #2600706
    David
    Staff
    Customer Support

    You’re welcome

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.