<div data-role="header" id="commonHead">
<div data-role="navbar">
<h3 id="pageHeaderH1" alt="my root way to home" style="text-align:center;">myRWTH</h3>
<div data-role="controlgroup" data-type="horizontal">
<a href="index.html" data-role="button">Yes</a>
<a href="index.html" data-role="button">No</a>
<a href="index.html" data-role="button">Maybe</a>
</div>
</div>
</div>
这是我的代码,但按钮不适合内容宽度,但与左侧对齐。我不明白我为什么不工作。有什么想法吗?
更新:我不知道为什么,但它不会起作用。我的解决方法是
<div data-role="header" id="commonHead" data-theme="b" >
<div data-role="navbar" data-iconpos="right">
<h3 id="pageHeaderH1" alt="my root way to home" style="text-align:center;" data-mini="true">myRWTH</h3>
<ul>
<li><a href="#popupBasic" data-rel="popup" data-type="vertical" data-icon="gear" data-iconpos="bottom">Anzeigeoptionen</a>
<div data-role="popup" id="popupBasic" data-theme="b">
<a id="ownPosition" data-role="button" data-icon="home" data-inline="true">Eigene Position</a>
<a id="ownPosition" data-role="button" data-icon="minus" data-inline="true">Mensen</a>
<a id="ownPosition" data-role="button" data-icon="minus" data-inline="true">HSP</a>
<a id="ownPosition" data-role="button" data-icon="minus" data-inline="true">Gebäude</a>
<a id="ownPosition" data-role="button" data-icon="minus" data-inline="true">Haltestellen</a>
<a id="ownPosition" data-icon="delete" data-icon="home" data-inline="true">Alle ausblenden</a>
</div>
</li>
</ul>
</div>
</div>
最佳答案
你可能需要调整一下,这是一个技巧:
http://jsfiddle.net/kewRs/
JS公司:
// override the jQM CSS
var cbnb = $('#customButtonNavbar');
var numberOfButtons = ($('.customButton').length > 0) ? $('.customButton').length:1;
var widthOfButtons = (Math.round(100 / numberOfButtons));
cbnb.children('.ui-controlgroup-controls').attr('style', 'width:100%;');
cbnb.children().children().attr('style', 'width:'+widthOfButtons+'%;');
HTML格式:
<div data-role="header" id="commonHead">
<div data-role="navbar">
<h3 id="pageHeaderH1" alt="my root way to home" style="text-align:center;">myRWTH</h3>
<div data-role="controlgroup" data-type="horizontal" id="customButtonNavbar">
<a href="index.html" data-role="button" class="customButton">Yes</a>
<a href="index.html" data-role="button" class="customButton">No</a>
<a href="index.html" data-role="button" class="customButton">Maybe</a>
</div>
</div>
</div>