Below is a sample code. Sketched a small mobile menu with a switch, when you click on that, the content area shifts its side, and the mobile menu leaves on the left.
at the same time, a side scroll appears on the mobile device, I thought that the problem would be solved if I wrote overflow-x: hidden to my body , and it helped only on the PC, and on the mobile phone you can still slide the content backwards with your finger.
I know that you can additionally set position: fixed , but this is not my case since the menu switch icon is supposed to be fixed too. That is, when scrolling, stay in the upper left corner.
At the same time, when you click on it, the content will twitch and scroll to the top of the page. In general, this crutch is not my case.
Therefore, I would like to know how to get rid of the side sroll on a mobile device. Without using position: fixed for body
$('.toggle').click(function() { if ($('.menu').hasClass('active')) { $('.menu, .content').removeClass('active'); } else { $('.menu, .content').addClass('active'); } }) body { margin: 0; padding: 0; overflow-x: hidden; } .content { display: block; position: relative; height: 1000px; background: #ccc; transition: 500ms; transform: translate(0, 0); } .content.active { transform: translate(290px, 0); } .menu { display: block; position: fixed; left: 0; height: 100%; z-index: 1; width: 290px; background: #5fba7d; overflow-y: auto; transform: translate(-100%, 0); transition: 500ms; } .menu.active { transform: translate(0, 0); } .toggle { display: block; position: relative; width: 70px; background: #eee; padding: 10px 15px; box-sizing: border-box; cursor: pointer; } span { display: block; position: relative; height: 4px; width: 100%; background: #000; margin: 10px 0; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script> <div class="menu"> <div class="menu-inner"> <h2>Меню</h2>ссылка<br/>ссылка<br/>ссылка<br/>ссылка<br/>ссылка<br/>ссылка<br/>ссылка<br/>ссылка<br/> ссылка <br/>ссылка<br/>ссылка<br/>ссылка<br/>ссылка<br/>ссылка<br/>ссылка<br/> </div> </div> <div class="content"> <div class="toggle"> <span></span> <span></span> <span></span> </div> Это область контента текст текст текст </div>