Chrome mobile ignoring overflow

不羁的心 提交于 2019-12-24 13:46:12

问题


I'm playing around with creating a webapp for android. I've been using phonegap with JQM, but I've reached a problem.

I'm implementing a slide-in menu, and for that I've found a simple example on the internet.

http://www.aldomatic.com/jqm/fb-menu-style/

This simple menu slides in from the left, and that part works great, but when i try to slide it in i get a problem. The whole page scrolls, and this is despite me having

#mobileViewport {
    overflow: hidden;
}

(The body tag has the id of mobileViewport

I have tried adding it to the html tag too, but to no avail.

Is this a bug? and is there any workaround?


回答1:


By default, JQM pages are positioned absolutely, outside of the flow of their containing element (if the containing element is statically positioned).

Adding overflow:hidden on the containing element (body) is therefore not going to help.

If you apply position:relative to #mobileViewport that should cause the JQM mobile pages to now flow correctly from the containing element and the overflow:hidden should work.

However, I suspect that is probably not a good idea and bound to cause other CSS display issues. (I recall playing around with that myself one time and having other issues as a side-effect)

Probably a better idea is adding the overflow:hidden to the JQM page elements themselves.

<body class="ui-mobile-viewport">
  <div id="mypage" data-role="page" class="ui-page">
  ...
  </div>
</div>

#mypage {
   overflow:hidden;
}

NOTE: If you have a footer, you might want to apply the overflow:hidden to the child .ui-content element instead.



来源:https://stackoverflow.com/questions/14094433/chrome-mobile-ignoring-overflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!