我有以下HTML:
<input type="radio" name="beds" value="1" />1+
<input type="radio" name="beds" value="2" />2+Run Code Online (Sandbox Code Playgroud)
如何更改单选按钮和"1+"文本之间的间距?我希望文本更接近单选按钮,但浏览器在两个元素之间插入一定量的未定义填充.
cas*_*nca 41
许多HTML元素都有默认的边距设置.您可以覆盖它并将其设置为0.在您的情况下,您想要重置margin-right单选按钮:
<input type="radio" name="beds" value="1" style="margin-right: 0" />1+
Run Code Online (Sandbox Code Playgroud)
您可能希望将其添加到样式表中,以便它适用于所有单选按钮:
input[type="radio"] {
margin-right: 0;
}
Run Code Online (Sandbox Code Playgroud)
Yi *_*ang 12
你需要这个label元素.
<input type="radio" name="beds" value="1" id="first" /><label for="first">1+</label>
<input type="radio" name="beds" value="2" id="second" /><label for="second">2+</label>
Run Code Online (Sandbox Code Playgroud)
然后你可以像这样设计:
label {
margin-left: -3px;
}
Run Code Online (Sandbox Code Playgroud)
另请注意,for为可访问性目的使用该属性.
| 归档时间: |
|
| 查看次数: |
82471 次 |
| 最近记录: |