【发布时间】:2013-04-27 05:41:23
【问题描述】:
我正在开发一个 jquery/PhoneGap 应用程序。我一直在努力让按钮按照我想要的方式运行。简而言之,我正在努力实现以下目标:
- 我放置了一组六个 Jquery-Mobile 按钮(迷你、普通或按钮组)。
- 上面的集合需要在一条水平线上,所以我把它们放在了一个 div 中。
按钮的数量及其文本是动态变化的,所以我需要一个 CSS/JS 技巧,允许我根据 div/屏幕大小调整按钮大小和文本大小。当我开始使用 Jquery mobile 时(两周前),我认为这将是一个基本功能 :) 但是唉!
我现在正在尝试的一些代码是:
//TO CREATE BUTTONS
for(var button_id=0; button_id < window.g_maxLength/2; button_id++){
var bt_id= "<button class =\"tile\" data-theme=\"e\" data-inline=\"true\" data-mini=\"true\" id =\"button_tid"+button_id+"\";>.</button>";
$("#buttoncontainer1").append($(bt_id));
}
//HTML
<div id="tiled" align="center">
<div data-role="controlgroup" data-type="horizontal" id="buttoncontainer1">
<!-- Button will be added by JS-->
</div>
</div>
//CSS
#tiled {
align:center;
height:23%;
position:absolute;
text-align :center;
padding: 1px;
width:90%;
top:73%;
margin-right:4%;
margin-left:4%;
background-color:#b0e0e6;
border-radius: 10px;
border-width: 3%;
border-style:double;
现在我所拥有的在小屏幕设备上运行良好,但是一旦我在大屏幕设备上打开我的应用程序,按钮看起来非常小,并且有很多空白空间。在这里的任何帮助将不胜感激!
PS:也使用了媒体查询 - 但不知何故,它们在 jquery-mobile 上不起作用。
@media (min-width: 500px) {
html { font-size: 120%; }
}
【问题讨论】:
-
您可以使用
ui-grid布局执行与fiddle.jshell.net/Palestinian/DTPZx 类似的操作。在 JQM 自定义 CSS 中,每个属性都应以!important结尾以覆盖 JQM 样式。 -
谢谢,如果我能弄清楚字体大小问题,这通常可以工作:)。虽然它不适用于按钮组。
-
是的,我错过了控制组的事情。
-
查看jsfiddle.net/Palestinian/UYa4Y,如果您有任何意见,请告诉我。更改“结果”窗口大小并点击“运行”。
-
这正是我需要的@Omar。谢谢,看起来很复杂,但我会解构它:)。
标签: javascript css jquery-mobile button