document.addEventListener('DOMContentLoaded', function() { jQuery(function($){ if ($(window).width() 40) { if(mywindow.scrollTop() > mypos) { $('.stickyheaders').addClass('headerup'); } else { $('.stickyheaders').removeClass('headerup'); } } mypos = mywindow.scrollTop(); }); } }); }); .stickyheaders{ -webkit-transition: transform 0.34s ease; transition : transform 0.34s ease; } .headerup{ transform: translateY(-110px); /*adjust this value to the height of your header*/ }