简体   繁体   English

jQuery Mobile 1.42中每个屏幕底部的空白

[英]White Space in bottom of every screen in jquery mobile 1.42

Hi iam using jquery mobile 1.42 to develop web application. 您好iam使用jquery mobile 1.42开发Web应用程序。 Every thing works great except unwanted white space occurring in bottom of window on every pages. 除了在每页窗口底部出现不需要的空白外,其他所有功能都可以正常工作。 I have only header and content. 我只有标题和内容。 Iam not using footer. 我不使用页脚。 can any one guide me. 谁能指导我。

You need to understand how jQuery Mobile pages works. 您需要了解jQuery Mobile页面的工作方式。 Footer and header are fixed with fixed height values. 页脚和页眉具有固定的高度值。 Content is on the other hand stretchable so it will resize according to its inner content, it will NEVER automatically resize to take rest of available space, left after footer and header. 另一方面,内容是可伸缩的,因此它将根据其内部内容调整大小,并且永远不会自动调整大小以占用剩余的可用空间,而在页脚和页眉之后。 Space not covered by content is a white space you are mentioning. 内容未涵盖的空间是您提到的空白。

There are two available solutions two your problem, one is CSS based and second one is JavaScript based. 有两个可用的解决方案,两个是您的问题,一个是基于CSS的,第二个是基于JavaScript的。

CSS solution: CSS解决方案:

.ui-content {
    padding: 0;
    position: absolute !important;
    top : 40px !important; 
    right : 0;
    bottom : 40px !important; 
    left : 0 !important;    
}

40px is here because of header and footer, set it to 0 if you don't need them. 由于页眉和页脚是40px,如果不需要它们,请将其设置为0。

Working example: http://jsfiddle.net/Gajotres/hJVuM/ 工作示例: http : //jsfiddle.net/Gajotres/hJVuM/

JavaScript solution JavaScript解决方案

function getRealContentHeight() {
    var header = $.mobile.activePage.find("div[data-role='header']:visible");
    var footer = $.mobile.activePage.find("div[data-role='footer']:visible");
    var content = $.mobile.activePage.find("div[data-role='content']:visible:visible");
    var viewport_height = $(window).height();

    var content_height = viewport_height - header.outerHeight() - footer.outerHeight();
    if((content.outerHeight() - header.outerHeight() - footer.outerHeight()) <= viewport_height) {
        content_height -= (content.outerHeight() - content.height());
    }
    return content_height;
}

Working example: http://jsfiddle.net/Gajotres/5Qu6P/ 工作示例: http : //jsfiddle.net/Gajotres/5Qu6P/

Ream more about this topic here . 在这里更多地讨论这个话题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM