简体   繁体   English

jQuery mobile:为桌面浏览器设置宽度和高度

[英]jquery mobile: set width and height for desktop browser

I'm using jquery mobile for emulating iphone application and i have a problem with content width and height at desktop browser. 我正在使用jquery mobile来模拟iphone应用程序,并且在桌面浏览器上出现内容宽度和高度问题。 Problem with width can be solved that way (width = 320px and content align center): 宽度问题可以通过这种方式解决(宽度= 320px,内容居中对齐):

html { background-color: #333; }
    @media only screen and (min-width: 321px){
    .ui-page {
      width: 320px !important;
      margin: 0 auto !important;
      position: relative !important;
    }
    }
But this causes useless background under footer. 但这会导致页脚下无用的背景。 I guess that background for ui-page can be replaced and one can add extra div with background for content (between header and footer), but there should be better way. 我猜想可以替换ui页面的背景,并且可以为内容添加额外的div背景(在页眉和页脚之间),但是应该有更好的方法。

So the question is how to set width and height for content, when it is opened in desktop browser? 因此,问题是在桌面浏览器中打开内容时如何设置内容的宽度和高度?

Update: Here is example . 更新:这是示例

you can try to remove the background of the page element and set it at the content. 您可以尝试删除页面元素的背景并将其设置为内容。 here is an example code: 这是一个示例代码:

CSS 的CSS

.ui-page.ui-body-c {
  background: none transparent;
}

.ui-content {
  background: #f0f0f0;
}

You could use javascript to resize the .ui-page's height on page load - here's a jQuery example: 您可以使用JavaScript来调整页面加载时.ui页面的高度-这是一个jQuery示例:

$(document).ready(function(){

    if($(window).height() >= 480)
    {
        $('.iu-page').height(480);
    }

});

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

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