2011-03-04 110 views

回答

0

你可以簡單的通過CSS指定此...

例如:

CSS

#wrapper {width:95%} 

HTML

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Page Title</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" /> 
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js"></script> 
    <script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script> 
</head> 
<body> 

<div id="wrapper"> 
<div data-role="page"> 

    <div data-role="header"> 
     <h1>Page Title</h1> 
    </div><!-- /header --> 

    <div data-role="content"> 
     <p>Page content goes here.</p>  
    </div><!-- /content --> 

    <div data-role="footer"> 
     <h4>Page Footer</h4> 
    </div><!-- /footer --> 
</div><!-- /page --> 
</div> 

</body> 
</html> 

您還可以通過這樣做動態:

$("div[data-role='page']").css('width',$("#container_element").innerWidth()+"px"); 
+1

自'data-role =「頁面指定'#wrapper'的寬度不起作用''div有'position:absolute'。你提供的jQuery片段確實會改變寬度,但它保留在頁面的左上角,而不管它的容器位於何處。 – mindeavor 2011-03-06 20:03:57

+1

更不用說那是圍繞着jQuery Mobile提供的框架。當您只需使用已有的包裝或類時,無需添加額外的包裝或類。 – commadelimited 2012-03-14 19:53:47

0

尺寸是自動的。如果在頁面div之外創建div並將其設置爲浮點型和寬度(以像素爲單位),則它應該在頁面div旁邊正確顯示。

3

只需在CSS文件中設置此行。讓它變得非常簡單。如果喜歡,則將最大寬度更改爲寬度。

.ui-page { max-width:500px; }