Floating block using JQuery


 $(function() {
  var fixedelement = $("#left_fixed_div");  
  var offset = fixedelement.offset(); 
  var topPadding = 15;
  $(window).scroll(function() {
  if ($(window).scrollTop() > offset.top) {
    fixedelement.stop().animate({marginTop: $(window).scrollTop() - offset.top + topPadding});
  }
  else {
    fixedelement.stop().animate({marginTop: 0});
  };});
});

Comments

Popular posts from this blog

PHP - How to increase size of POST value in php

D8 KernelEvents constants

D8 - Attach file programmatically to a node