• Hello everyone.
    I want to make a sticky block using this script

    $(window).scroll(function() {
    var sb_m = 80; /* top and bottom padding */
    var mb = 300; /* footer height with a margin */
    var st = $(window).scrollTop();
    var sb = $(".loginform");
    var sbi = $(".loginform #loginform");
    var sb_ot = sb.offset().top;
    var sbi_ot = sbi.offset().top;
    var sb_h = sb.height();
    
    if(sb_h + $(document).scrollTop() + sb_m + mb < $(document).height()) {
        if(st > sb_ot) {
            var h = Math.round(st - sb_ot) + sb_m;
            sb.css({"paddingTop" : h});
        }
        else {
            sb.css({"paddingTop" : 0});
        }
    }
    });

    on bare HTML everything works fine.
    if add a script to theme an endless scroll appears
    here can see bug
    this behavior occurs if add a widget to footer
    please tell me what is problem?

    • This topic was modified 3 years, 3 months ago by milatovskaja.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there,

    why use Javascript ?
    You can use the CSS position: sticky; property on your loginform element.

    As long as the Container ( wp-block-column ) it sits inside of is 100% the height of its parent container (wp-block-columns ) , that element will stick on scroll.

    Which looks to be the case as you have already made those a flex column with 100% height.

    Thread Starter milatovskaja

    (@milatovskaja)

    maybe you’re right
    I will heed your advice

    You’re welcome

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘problem with sticky block’ is closed to new replies.