Site logo

[Resolved] Offset anchors with fixed header

Home Forums Support [Resolved] Offset anchors with fixed header

Home Forums Support Offset anchors with fixed header

Viewing 13 posts - 46 through 58 (of 58 total)
  • Author
    Posts
  • #228273
    Bin

    Yes, I did. Now it works fine for all links EXCEPT the top menu! There I put “smooth” to the customizer option for menu classes. Please have a look at: http://www.anonymio.de

    #228356
    Tom
    Lead Developer
    Lead Developer

    Ah, for it to work with the menu you might have to replace this:

    a.smooth

    With this:

    li.smooth > a

    #228373
    Bin
    <script>
    jQuery(function($) {
    	$('li.smooth > a[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 - 70
    				}, 500);
    				return false;
    			}
    		}
    	});
    });
    </script>

    Does NOT work at all!!!

    #228505
    Tom
    Lead Developer
    Lead Developer

    You’re using a caching plugin. You need to clear the cache after making any changes like this.

    #228602
    Bin

    Sure. Even with clear cache there is no offset-effect. But ONLY by clicking the TOP-Menu button on the same page! Coming from a diffent page it works!

    #228674
    Tom
    Lead Developer
    Lead Developer

    I’m still seeing the old code in your HTML.

    For testing, it would be best if your cleared your caching plugin and then disabled it completely.

    #228693
    Bin

    Yes, because I put in a.smooth again. li.smooth > a DEFINITELY doesn’t work on my site! Tested completely without cache… 😰

    #229130
    Bin

    So, at the end I am using ‘smooth’ AND <div id="test"><!-- anchor --></div> in a separate section with zero padding. Works fine so far. BUT there is still a strange behavior while clicking the top menu buttons. Sometimes they do not hit exactly the aimed anchor on a different page! If you have a solution for that issue, please don’t hesitate to tell me! ;)) Regards, Bin

    #229209
    Tom
    Lead Developer
    Lead Developer

    Any chance you can show me with some details? Like which link to click etc..

    #324115
    Heidi

    Hi All,

    I am so close to getting this to work, but can’t quite. I am using a left sidebar on a page with sections. The left sidebar contains the secondary menu (the same menu is also a slide-out menu).

    Section Page (Resources) on My Website

    I’ve got each section labeled with it’s own custom id, e.g. “business-law”.
    I’ve got each section labeled with the same custom class of “practice”

    I’ve added this code to the css, but can’t get it to work for either the slide-out menu or the secondary nav menu. what am I missing? Thanks for advice as always.

    a.practice:before {
        display: block;
        position: relative;
        top: -100px; /* height of sticky navigation */
        visibility: hidden;
    }
    #324253
    Tom
    Lead Developer
    Lead Developer

    Instead of a.practice, try div.practice.

    #528239
    Tom
    Lead Developer
    Lead Developer

    GP Premium now has a native smooth scroll option, which you can find in “Customize > General”.

    #532149
    Michael

    Thanks Tom! This just saved me some extra grey hairs. Perfect solution.

    Loving the theme down here in Australia!

Viewing 13 posts - 46 through 58 (of 58 total)
  • You must be logged in to reply to this topic.