本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长


+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

按钮内的标签 - 单击按钮并激活标签

发布于2023-03-24 16:28     阅读(517)     评论(0)     点赞(4)     收藏(4)


When you click on this button, it will only checkoff the checkbox if you click on the "Hello" text. If you click on the button but not the text, it will not check off the box. How can I make it so no matter where I click on the button, it will check off the box?

<button>
    <label for="myId">Hello</label>
</button>


<input id="myId" type="checkbox" />

解决方案


您需要使标签成为按钮的全宽和全高,如下所示:

<button style="padding: 0;">
    <label style="display: block; padding: 20px;" for="myId">Hello</label>
</button>


<input id="myId" type="checkbox" />

这是小提琴: https: //jsfiddle.net/hxoqrf7v/




所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:http://www.qianduanheidong.com/blog/article/516821/55c81f030046e7fe2576/

来源:前端黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

4 0
收藏该文
已收藏

评论内容:(最多支持255个字符)