When changing the width of the browser, the body should leave (left: -181px) and stand in place (left: 0). Everything, in principle, works. Here is the working piece of code:
$(window).resize(function(){ if ($(document).width() >= 751){ $('body').animate({ left: '0' }); } if($('.menn').css('right') == '0px' && $(document).width() < 751){ $('body').animate({ left: '-181' }); } }); But it takes a very long time to react. For example, when narrowing the screen, the program “thinks” for a very long time and only then the animation is applied to the body left: '-181'.