gpt4 book ai didi

css - 单选按钮宽度

转载 作者:行者123 更新时间:2023-11-28 18:37:43 25 4
gpt4 key购买 nike

我需要更改分组单选按钮的宽度,但我做不到。我尝试添加 style=width:...px 但它不起作用。

我正在使用 jQuery Mobile 和 Cordova。

我该如何解决?

HTML

<div data-role="fieldcontain" data-inline="true">
<fieldset data-role="controlgroup" data-inline="true">
<legend>Question1:</legend>
<input type="radio" name="radio-choice" id="radio-choice-1" value="choice-1"/>
<label for="radio-choice-1">OK</label>
<input type="radio" name="radio-choice" id="radio-choice-2" value="choice-2"/>
<label for="radio-choice-2">KO</label>
<input type="radio" name="radio-choice" id="radio-choice-3" value="choice-3"/>
<label for="radio-choice-3">N.A.</label>
<input type="text" name="name" id="basic" value=""/>
</fieldset>
</div>

最佳答案

尝试申请 width样式到 <label>元素:

<div data-role="fieldcontain" data-inline="true">
<fieldset data-role="controlgroup" data-inline="true">
<legend>Question1:</legend>
<input type="radio" name="radio-choice" id="radio-choice-1" value="choice-1"/>
<label for="radio-choice-1" style="width: 100px;">OK</label>
<input type="radio" name="radio-choice" id="radio-choice-2" value="choice-2"/>
<label for="radio-choice-2" style="width: 100px;">KO</label>
<input type="radio" name="radio-choice" id="radio-choice-3" value="choice-3"/>
<label for="radio-choice-3" style="width: 100px;">N.A.</label>
<input type="text" name="name" id="basic" value=""/>
</fieldset>
</div>

您可以在this fiddle 中看到结果.

请注意,如果您希望所有标签都具有相同的宽度,创建一个 CSS 规则将该宽度分配给一个类,然后将该类添加到您的标签将减少代码重复。

关于css - 单选按钮宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12276592/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com