div溢出导致滚动行为异常
P粉350036783
P粉350036783 2023-09-10 13:50:38
0
1
539

我有以下示例代码:

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>

在具有文本的div中滚动时,有时候body div似乎也会滚动。如果我快速滚动到文本div的顶部,这种情况似乎会经常发生。

如何阻止这种行为?

P粉350036783
P粉350036783

全部回复(1)
P粉652495194

您可能还需要在html元素上隐藏溢出。特别是对于iOS/苹果设备,我认为溢出滚动的问题发生在html元素上(现在无法测试)。

html, body {
  overflow: hidden;
}
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!