$(document).scroll(function(){ if (window.matchMedia("(max-width: 767px)").matches){ $(".glossary-posting-right-wrapper").css({"margin-left": "","position":"","width":""}); } else{ if($(window).scrollTop()<=553){ $(".glossary-posting-right-wrapper").css({"margin-top":$(window).scrollTop()}); } } });