如何增加< a>的可点击区域标签按钮? [英] How to increase the clickable area of a <a> tag button?

查看:116
本文介绍了如何增加< a>的可点击区域标签按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从此帖子了解到,这些帖子始终使用< a> 标签或< button> 标签来制作按钮。现在,我尝试使用< a> 标记。我的问题是:有什么办法可以增加标签的可点击区域?假设我在div框中使用< a> 。我希望整个div框成为一个按钮。我可以将点击区域更改为整个div框吗?
感谢您的帮助。

I have learnt from this post that always use <a> tags or <button> tags to make button. Now I'm trying to use <a> tag. My question is: is there any way to increase the tag clickable area? Say I'm using <a> in a div box. I want the whole div box to become a button. Can I change the clicking area to the whole div box? Thanks for you help.

推荐答案

编辑:

@ t1m0thy的答案比我的优雅,最好听从他的建议。

@t1m0thy's answer is more elegant than mine, better follow his advices.

此外, @aldemarcalazans 在评论中建议的漂亮链接: https://davidwalsh.name/html5-buttons

Also, nice link proposed by @aldemarcalazans in the comments: https://davidwalsh.name/html5-buttons.

原始答案:

使用< a /> ,当您需要链接( anchor a )时。需要按钮时使用<按钮/>

Use <a /> when you need a link (the a of anchor). Use <button /> when you need a button.

也就是说,如果您确实需要扩展< a /> ,在其上添加CSS属性 display:block; 。然后,您可以指定宽度和/或高度(即好像它是< div /> )。

That said, if you really need to expand an <a />, add the CSS attribute display: block; on it. You'll then be able to specify a width and/or a height (i.e. as if it were a <div />).

这篇关于如何增加&lt; a&gt;的可点击区域标签按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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