升级jQuery Mobile至1.5.0-alpha.1后Header按钮位置失效求助
解决方法
jQuery Mobile 1.5.0-alpha.1 对头部(header)按钮的布局逻辑做了调整,不再自动将头部内的按钮默认分配到左右两侧,需要显式指定按钮位置。
直接修改头部内的两个按钮标签,分别添加 data-position="left" 和 data-position="right" 属性即可修复布局:
<body style="background-color: #222"> <div data-role="page" data-position="fixed" id="pageDiv"> <div data-role="header" data-theme="b" data-position="inline"> <a data-icon="back" class="headerButton" data-role="button" data-rel="back" data-position="left">Back</a> <h1>Mobil - @ViewBag.HeaderString</h1> <a data-icon="minus" id="logout" data-role="button" class="headerButton" href="@Url.Action("LogOff", "Account")" data-position="right">Exit</a> </div> <div data-role="content" data-theme="a" style="min-height:inherit"> @RenderBody() </div> </div>
如果添加位置属性后仍有样式问题,可尝试移除头部的 data-position="inline" 属性,改用 data-position="fixed"(与外层page的属性保持一致),因为1.5版本对inline位置的处理也有更新。
内容的提问来源于stack exchange,提问作者Emre Altuntaş
相关产品推荐
相关产品推荐

