Answers for "change element position after scroll"

0

change element position after scroll

var header = $('#header');
    var ad = $('#ad');
    var min_scroll = 25; // Set your minimum scroll amount here
    $(window).scroll(
        function() {
            var t = $(window).scrollTop();
            if (t > min_scroll) {
                // define your scroll CSS here
                header.css({position: "relative"});
                ad.css({position: "relative"});
            } else {
                // define your non-scrolled CSS here
                header.css({position: "fixed"});
                ad.css({position: "absolute"});
            }
        }
    );
Posted by: Guest on September-17-2020

Code answers related to "change element position after scroll"

Browse Popular Code Answers by Language