2012-05-19 132 views
2

我正在研究JQuery Mobile应用程序。这个应用在“内容”部分有一个按钮,我想在“内容”部分的底部对齐。我的html是这样的:垂直对齐jQuery Mobile中的按钮

<div id="myPage" data-role="page"> 
    <div data-role="header" data-position="fixed"> 
     <a href="/page1" data-icon="arrow-l" data-iconpos="notext" class="ui-btn-left jqm-home">Back</a> 
     <h1>My App</h1> 
     <a href="/page3" class="ui-btn-right" data-role="button" rel="external" data-transition="slide">Next</a> 
    </div> 

    <div data-role="content"> 
     <ul data-role="listview"> 
      <li data-role="list-divider"> 
       Step 2 of 3 
      </li>    
     </ul><br /><br /> 

     <!-- Main content Goes Here --> 
     <br /> 

     <!-- I want the following button to be vertically aligned to the bottom so that it sits on top of the footer content --> 
     <input type="button" value="View Table" onclick="return viewTable();" data-mini="true" /> 

    </div> 

    <div data-role="footer" class="ui-bar" data-position="fixed"> 
     <!-- My Footer Content --> 
    </div> 
</div> 

如何垂直对齐该按钮,使其刚好在页脚之上?如果我把它放在页脚本身,由于使用的颜色,它看起来不正确。

回答

2

从我头顶上做到这一点的一种方法是将你的按钮包装在一个ID与一个div,并添加一些绝对位置底部的CSS。例如:

HTML

<div id="viewTableBtn"> 
    <input type="button" value="View Table" onclick="return viewTable();" data-mini="true" /> 
</div> 

CSS

#viewTableBtn{ 
    position:absolute; 
    bottom:15px; 
    width:94%; 
}​