html - 如何放大表单元素周围的 'click-zone'?

标签 html css radio-button

我希望扩大单选按钮周围的可点击区域。

这就是我所拥有的:

have

这就是我想要的:

want


我尝试了以下( jsFiddle here ),但是 widthheight属性似乎不适用于 <label> ...

HTML:

<div style="white-space:nowrap;">
    <span class="radio_option">
        <input type="radio" id="one" name="click_item" value="1" />
        <label class="radio_label" for="one">First Item</label>
    </span>
    <span class="radio_option">
        <input type="radio" id="two" name="click_item" value="2" />
        <label class="radio_label" for="two">Second Item</label>
    </span>
</div>

CSS:

span.radio_option {
    border: 1px solid gray;
}
span.radio_option:hover {
    background: #E0E0E0;
}
label.radio_label {
   width: 100px;
    height: 30px;
}
label.radio_label:hover {
    cursor: pointer;
}

最佳答案

更新:span.radio_option 添加填充。添加 display:inline-block 并设置宽度。

span.radio_option {
    border: 1px solid gray;
    padding: 5px 10px;
    display:inline-block; 
    width:120px;
}

在这里摆弄:http://jsfiddle.net/2bLtD/15/

关于html - 如何放大表单元素周围的 'click-zone'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17142662/

相关文章:

html - 页脚隐藏内容

javascript - 我的 jquery 验证添加方法密码规则出现问题

html - 如何使第二行的 div 与第一行的 div 垂直对齐

css - Twitter Bootstrap float 响应容器

java - Android 滚动列表后会选择多个单选按钮。改变其状态

不需要 WordPress 联系表 7 radio

html - JSF 2.0 页面中的 SVG 图形对象入门

html - 调整布局图像和大小

html - 在不使用 flex 的情况下在 anchor 标记内垂直对齐

android - 在 Android 中以编程方式添加到 RadioGroup 时,RadioButtons 具有不同的样式