JavaScript Developer
JavaScript Developer

Reputation: 4008

Vertically Align a Button in JQuery Mobile

I'm working on a JQuery Mobile app. This app has a button in the "content" portion that I want to align at the bottom of the "content" section. My html looks like this:

<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>

How do I vertically align that button so that it is just above the footer? If I put it in the footer itself it doesn't look right because of the colors used.

Upvotes: 2

Views: 4891

Answers (1)

codaniel
codaniel

Reputation: 5253

One way to do this off the top of my head is to wrap your button in a div with an id and add some css that absolutely positions to bottom. Example:

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%;
}​

Upvotes: 2

Related Questions