Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to let jquery mobile controlgroup width 100%?

i'm useing jquery mobile to do a demo... i want to let the width of localnav be 100%... but i don't know how to do that... code here...

<ul data-role="controlgroup" data-type="horizontal" class="localnav">
    <li><a href="#" data-role="button" data-transition="fade" class="ui-btn-active">111</a></li>
    <li><a href="#" data-role="button" data-transition="fade">222</a></li>
    <li><a href="#" data-role="button" data-transition="fade">333</a></li>
</ul>

help me pls...thank you...

like image 276
RogerWu Avatar asked Jun 07 '12 09:06

RogerWu


3 Answers

Here's what I did. Worked well.

CSS:

<style>
    .ui-grid-a, .ui-grid-a .ui-controlgroup-controls {width: 100%}
    #homePageButton {width:49%;float:left;margin-left:1%}
    #logOutButton {width:49%}
    #footer {height:45px}
</style>

HTML:

<div data-role="footer" data-position="fixed" id="footer">
    <div data-role="controlgroup" data-type="horizontal" class="ui-grid-a">
        <a href="#" data-role="button" data-icon="home" id="homePageButton">Home Page</a>
        <a href="#" data-role="button" data-icon="forward" data-iconpos="right" id="logOutButton">Log Out</a>
    </div>
</div>

Result: enter image description here

like image 190
joey_g216 Avatar answered Sep 24 '22 12:09

joey_g216


Take a look at JQuery Mobile's navbar Though it's normally used in a header/footer, it can be used elsewhere. It will produce a full-width bar containing your buttons.

       <div data-role="navbar">
            <ul>
                <li><a href="#" data-icon="plus" data-role="button">Button1</a></li>
                <li><a href="#" data-icon="minus" data-role="button">Button2</a></li>
                <li><a href="#" data-icon="check" data-role="button">Button3</a></li>
            </ul>
        </div>
like image 35
Kyle Duncan Avatar answered Sep 24 '22 12:09

Kyle Duncan


Not sure why you are trying to wrap a <ul> as a controlgroup. But you can have a full-width ControlGroup with the following approach:

<div data-role="controlgroup" data-type="horizontal" class="localnav">
    <a href="#" data-role="button" data-transition="fade" class="ui-btn-active">111</a>
    <a href="#" data-role="button" data-transition="fade">222</a>
    <a href="#" data-role="button" data-transition="fade">333</a>
</div>

And in CSS, split the width equally among the number of <a> elements:

a{width:33%;}

Sample jsfiddle: http://jsfiddle.net/pAuqm/1/

If you want to continue with <ul> based structure; you could have full width controlgroup with following CSS:

li{
    display: inline;
}
a{width:33%;}

Sample jsfiddle: http://jsfiddle.net/pAuqm/3/

like image 44
Nirmal Patel Avatar answered Sep 24 '22 12:09

Nirmal Patel