I used to run into similar problems and could never figure out workarounds, so I decided to use plugins like iScroll. This is such a simple task that I refuse to include a plugin in it - I want to prevent horizontal scrolling in iOS. This includes the rubber band effect for any content that may be on the page, but it is not visible.
From what I understand, I need to disconnect the rubber tape first, and then apply the touch scroll to the container element (which I gave “touch”). Not sure if this is the right approach?
$(document).bind('touchmove', function(e) { if (!e.target == '#touch') { e.preventDefault(); } });
Style for #touch
-webkit-overflow-scrolling: touch; overflow: hidden; height: 100%; @media only screen and (max-width: 768px) { width: 768px; }
This does not interfere with the horizontal width of 728 pixels, however, the user can still scroll and see hidden content. Ideas?
source share