jQuery Mobile popup content height exceeds window height

左心房为你撑大大i 提交于 2019-12-06 07:35:06

问题


The jQuery Mobile popup dimensions are limited to having a 15px margin on the left an right sides, and a 30px margin on the top and bottom. If the content is too large for these constraints, then the popup grows longer (not wider), so that the whole page must be scrolled to view the popup content.

I need to change this behavior such that the popup dimensions never exceed the height of the window, and such that the content scrolls vertically within the popup.

It is possible to limit the size of the popup thusly:

$('#popup').on({
  popupbeforeposition: function() {
    var maxHeight = $(window).height() - 30
    $('#popup').css('max-height', maxHeight + 'px')
  }
})

...but the popup content is the same, passing the bottom of the popup and still forcing the user to scroll the page, rather than the content within the popup.

How do I allow the popup content to scroll vertically within the popup?


回答1:


You should use:

$('#popup').css('overflow-y', 'scroll');    

Here's a working example: http://jsfiddle.net/Gajotres/mmRnq/

Final notes

If you want to find more about how to customize jQuery Mobile page and widgets then take a look at this article. It comes with a lot of working examples, including why is !important necessary for jQuery Mobile.



来源:https://stackoverflow.com/questions/14723788/jquery-mobile-popup-content-height-exceeds-window-height

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