I've got the following sample code:
body {
overflow: hidden;
}
#content {
height: 200px;
overflow-x: hidden;
overflow-y: auto;
outline: none;
}
<div id="content" tabindex="0">
<p>Bacon ipsum dolor amet capicola pig ribeye andouille. Brisket chuck ham biltong frankfurter landjaeger cupim kielbasa prosciutto. Capicola kevin chuck salami bacon. Shank t-bone strip steak shoulder tri-tip tenderloin turducken rump pork loin andouille
fatback bacon chicken shankle ground round.</p>
<p>Brisket turducken beef ribs picanha shank ribeye shoulder, pig rump strip steak. Prosciutto tri-tip strip steak pork, swine pork chop sausage meatloaf cupim pancetta. Venison jowl sirloin pig cow, short ribs strip steak rump shankle meatball. Corned
beef meatloaf short loin pork belly meatball swine, ham pancetta andouille sausage. Fatback short loin turducken pork loin, shank porchetta salami pork belly leberkas shankle picanha tenderloin doner ball tip. Spare ribs pastrami cow capicola sausage
jowl shank ball tip kevin ham chuck short loin.</p>
<p>Ground round sausage filet mignon pastrami shank. Tenderloin t-bone drumstick ground round, bresaola rump pork chop alcatra kevin turducken turkey. Corned beef flank picanha beef chicken. Pork loin pastrami short loin meatball chicken sausage alcatra
andouille venison.</p>
<p>Turkey alcatra pancetta spare ribs boudin filet mignon venison ball tip salami drumstick. Flank pastrami ball tip prosciutto bresaola, tenderloin beef ribs fatback beef brisket strip steak chicken biltong. Ham boudin pancetta, corned beef rump salami
chicken drumstick. Picanha cow flank swine fatback, hamburger frankfurter shank meatloaf ham hock. Pastrami pancetta prosciutto shoulder. Filet mignon sausage jowl biltong tail pork turkey boudin tongue short loin meatball flank pork belly.</p>
</div>
When scrolling in the div with the text in it, sometimes the body div seems to scroll too. If I scroll quickly to the top of the div with the text in it, it seems to happen with regular occurrence.
Can anyone help me stop this behaviour?
CodePudding user response:
I do not see the described behavior. I added a div
with a p
tag to show that the body is not scrolling with the inner content:
<div>
<p>Hello There!</p>
</div>
https://jsfiddle.net/6net70oa/7/
If this does not answer your question, please accurately describe your issue.
CodePudding user response:
You may also need to hide the overflow on the html
element as well. Especially for ios/apple devices, I think the overscroll thing happens on the html
element (can't test right now).
html, body {
overflow: hidden;
}