jquery - 单选按钮在 jquery 移动版本 1.0 中没有正确对齐中心?

标签 jquery jquery-ui html jquery-mobile radio-button

我在我的 jquery 移动应用程序中使用了单选按钮,我使用的是 jquery 移动 1.0 和 jquery 1.6.4。问题是它总是左对齐。所以,我试图在中心移动,但它不起作用。如何解决这个问题?提前致谢。

<div id="userOptionGroup" data-role="contain">
          <fieldset data-role="controlgroup" data-type="horizontal" data-theme="b" style="font-size:12px;border:2px;">
                <input type="radio" data-theme="b" name="radio-choice-b" id="radio-choice-wuser" value="windowUser"  checked="checked" />
                <label for="radio-choice-wuser" style="font-size: 12px;" class="ui-btn-section-active" id="lblWindowUser">win user</label>
                <input type="radio" data-theme="b" name="radio-choice-b" id="radio-choice-muser" value="mfileUser" />
                <label for="radio-choice-muser" style="font-size: 12px;" id="lblMfileUser">M file user</label>
          </fieldset>
          </div>

最佳答案

您必须将单选按钮包装在具有固定宽度的 div 中,并且在字段集上将边距设置为自动。方法如下 - 当然不使用内联 css 更整洁。

<fieldset data-role="controlgroup" data-type="horizontal" style="text-align: center">
  <div style="width: 200px; margin: 0 auto;">
   <input type="radio" name="radio-choice-1" id="radio-choice-1" value="choice-1" checked="checked" />
   <label for="radio-choice-1">A</label>
   <input data-theme="e" type="radio" name="radio-choice-1" id="radio-choice-2" value="choice-2"  />
   <label for="radio-choice-2">B</label>
 </div>
</fieldset>

关于jquery - 单选按钮在 jquery 移动版本 1.0 中没有正确对齐中心?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8252895/

相关文章:

javascript - 在页面加载时运行 jquery 延迟加载而不是滚动

javascript - 从具有 html 的变量中获取特定值

jquery - 创建模糊的背景效果

java - 将 ID 从 jQuery 自动完成 UI 框获取到 JSP 上的表单中

html - 图片高度尺寸与设置不符

javascript - 如何在javascript中获取字符串内指定单词的每个索引?

javascript - 处理输入类型 ='color' 上的对话框关闭事件

javascript - 使用 x 可编辑插件时出现 Uncaught ReferenceError

javascript - jquery mobile - 如何在从外部链接返回后正确加载页面

html - 为什么我的表格中的圆形单元格大小不同?