开发者

jQuery mobile listview and input button overlap

开发者 https://www.devze.com 2023-04-11 14:22 出处:网络
I have the following to display a list of items and a button underneath the list. However the button is overlapping on top of the list. I must be not putting some kind of data-role or another one of t

I have the following to display a list of items and a button underneath the list. However the button is overlapping on top of the list. I must be not putting some kind of data-role or another one of their attributes on it.

<div data-role="content" data-theme="b">    
    <div>
       <ul id="listOfSheets"开发者_高级运维 data-role="listview" >
     <li class="hidden"> <a href="_linkToSheet" data-ajax="false"> _sheetName</a></li>
      </ul>
    </div>  
    <input id="logout" type="button" value="Sign Out"    />
 </div><!-- /content -->

Here is what it looks like:

jQuery mobile listview and input button overlap


Live Example:

  • http://jsfiddle.net/B7nhA/ (the problem)
  • http://jsfiddle.net/B7nhA/1/ (the fix)

You're missing one of the attributes for the listview

data-inset="true"

HTML

<div data-role="content" data-theme="b">    
    <div>
        <ul id="listOfSheets" data-role="listview" data-inset="true">
            <li class="hidden"><a href="#" data-ajax="false">Link 1</a></li>
            <li class="hidden"><a href="#" data-ajax="false">Link 2</a></li>
            <li class="hidden"><a href="#" data-ajax="false">Link 3</a></li>
        </ul>
    </div>  
    <input id="logout" type="button" value="Sign Out" />
</div><!-- /content -->


i experienced the same problem. Here is my fix.

 <style>
 .ui-content .ui-listview
    {
        margin-top: 5px;
        margin-bottom: 5px;
    } 
</style>

JsFiddle Demo

You dont need to modify your markups.


How about inserting an line break befor the button.Not a clean solution I think.But it will work.

<div data-role="content" data-theme="b">    
    <div>
       <ul id="listOfSheets" data-role="listview" >
     <li class="hidden"> <a href="_linkToSheet" data-ajax="false"> _sheetName</a></li>
      </ul>
    </div> 
    <br>
    <input id="logout" type="button" value="Sign Out"    />
 </div><!-- /content -->


I used padding to solve this kind of problems. See below I added padding to the list-container div.

<div data-role="content" data-theme="b">    
  <div style="padding-bottom:20px">
    <ul id="listOfSheets" data-role="listview" >
        <li class="hidden"><a href="#" data-ajax="false">Link 1</a></li>
        <li class="hidden"><a href="#" data-ajax="false">Link 2</a></li>
        <li class="hidden"><a href="#" data-ajax="false">Link 3</a></li>
    </ul>
  </div>  
<input id="logout" type="button" value="Sign Out"    />

​​​

Here is a DEMO

0

精彩评论

暂无评论...
验证码 换一张
取 消