简体   繁体   English

使用CSS更改JQuery Mobile中复选框的宽度?

[英]Changing width of checkbox in JQuery Mobile using CSS?

I'm trying to set the width of my 3 checkboxes to be 33% each, but no matter what I do I'm not able to change the width at all. 我试图将我的3个复选框的宽度设置为每个33%,但无论我做什么,我都无法改变宽度。

The form/fieldset portion of my HTML looks like this: 我的HTML的表单/字段集部分如下所示:

<form class="form_attendance">
<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true" id="form_attendance">
    <legend>Attendance</legend>
    <input type="checkbox" name="checkbox1" id="checkbox1" class="selector">
    <label for="checkbox1">1</label>
    <input type="checkbox" name="checkbox2" id="checkbox2" class="selector">
    <label for="checkbox2">2</label>
    <input type="checkbox" name="checkbox3" id="checkbox3" class="selector">
    <label for="checkbox3">3</label>
</fieldset>
</form>

I've tried setting different widths to the input- form- and fieldset-components in CSS using both class and id but nothing happens. 我尝试使用class和id为CSS中的input-form-和fieldset-components设置不同的宽度,但没有任何反应

Does anyone have any idea? 有人有什么主意吗?

jQuery Mobile adds extra classes and html elements to your code. jQuery Mobile为您的代码添加了额外的类和html元素。 You need to target those. 你需要针对那些。 Best is if you use your browser inspector to check which elements you need to target. 最好的方法是使用浏览器检查器检查需要定位的元素。

In you case you need this CSS: 在你的情况下你需要这个CSS:

#form_attendance .ui-controlgroup-controls {
    width: 100%
}

#form_attendance .ui-checkbox {
    width: 33%;
}

Working Fiddle 工作小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM