如何制作一个具有大目标区域的HTML单选按钮? [英] How can I make an HTML radiobutton with a big target area?

查看:125
本文介绍了如何制作一个具有大目标区域的HTML单选按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像这样:





用户可以点击按钮的任何区域,并选择该单选按钮。



任何建议?



据我所知,单选按钮为自我关闭,不能包裹其他元素。


<最好的方法是将< input> 包装在< ; label> ,因为点击标签还具有集中其相关输入的效果:

  ; label> 
< input name =transfertype =radio>银行存款
< / label>

不需要javascript:演示: http://jsfiddle.net/GTGan/



如果您需要单独为标签文本设置样式,只需将其包装在< span>


Something like this:

Where the user would click on any area of the button and it would select that radio button.

Any suggestions?

As far as I can tell, radio buttons as self closed, and can't wrap around other elements.

解决方案

The best way is to just wrap the <input> in its <label>, as clicking a label also has the effect of focusing its associated input:

<label>
    <input name="transfer" type="radio">Bank Deposit
</label>

No javascript required: Demo: http://jsfiddle.net/GTGan/

If you need to style the label text separately, just wrap it in a <span>.

这篇关于如何制作一个具有大目标区域的HTML单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆