在身体上滚动div不适用于iPhone

时间:2023-01-17 13:11:06

I have a website with a menu. Sometimes the menu content is overflowing it's container and i need it to to be scrollable. It works fine on a pc. Yet on an iphone what happens is that when i try to scroll the menu, it scrolls the whole body instead. As a result, the entire view is being dragged down/up reveling a grey area at the top/bottom of the screen. This happens mostly in portrait mode, for some reason. In landscape, if i go easy on the swiping, i am able to scroll the menu content alone while the rest of the body stays put.

我有一个带菜单的网站。有时菜单内容溢出了它的容器,我需要它可以滚动。它在电脑上工作正常。然而在iphone上发生的事情是,当我尝试滚动菜单时,它会滚动整个身体。结果,整个视图被向下/向上拖动,陶醉在屏幕顶部/底部的灰色区域。出于某种原因,这主要发生在肖像模式下。在风景中,如果我轻松滑动,我可以单独滚动菜单内容,同时保持身体的其余部分。

Can anyone help with that?

任何人都可以帮忙吗?

Thank you!!


<html>
<style>
   #menu {
      overflow: scroll;
   }
</style>
<body>
   <div id="menu">
      --content--
   </div>
   <div id="mainPage">
      --content--
   </div>
</body>
</html>

1 个解决方案

#1


0  

This link could possibly help you... Hope it helps and good luck! :)

这个链接可能会帮助你...希望它有所帮助,祝你好运! :)

Background position not functioning as expected on Safari

背景位置在Safari上无法正常运行

Or just add this in the div's class

或者只是在div的类中添加它

background-position-x: 50%; (This will hopefully resolve your issue with the Safari browser) background-position-y: 0%; (This will hopefully resolve your issue with the Safari browser) background-position: center top; (This should work on the PC)

background-position-x:50%; (这有望解决您在Safari浏览器中遇到的问题)background-position-y:0%; (这有望解决您在Safari浏览器中遇到的问题)background-position:center top; (这应该适用于PC)

#1


0  

This link could possibly help you... Hope it helps and good luck! :)

这个链接可能会帮助你...希望它有所帮助,祝你好运! :)

Background position not functioning as expected on Safari

背景位置在Safari上无法正常运行

Or just add this in the div's class

或者只是在div的类中添加它

background-position-x: 50%; (This will hopefully resolve your issue with the Safari browser) background-position-y: 0%; (This will hopefully resolve your issue with the Safari browser) background-position: center top; (This should work on the PC)

background-position-x:50%; (这有望解决您在Safari浏览器中遇到的问题)background-position-y:0%; (这有望解决您在Safari浏览器中遇到的问题)background-position:center top; (这应该适用于PC)