How can I make an HTML radiobutton with a big target area?(如何制作具有大目标区域的 HTML 单选按钮?)
问题描述
类似这样的:
用户点击按钮的任何区域并选择该单选按钮.
Where the user would click on any area of the button and it would select that radio button.
有什么建议吗?
据我所知,单选按钮是自关闭的,不能环绕其他元素.
As far as I can tell, radio buttons as self closed, and can't wrap around other elements.
推荐答案
最好的办法是把 <input> 包裹在它的 <label> 中,因为单击标签也具有聚焦其相关输入的效果:
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>
无需 javascript:演示:http://jsfiddle.net/GTGan/
No javascript required: Demo: http://jsfiddle.net/GTGan/
如果您需要单独设置标签文本的样式,只需将其包装在 <span> 中即可.
If you need to style the label text separately, just wrap it in a <span>.
这篇关于如何制作具有大目标区域的 HTML 单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何制作具有大目标区域的 HTML 单选按钮?
基础教程推荐
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
