如何制作< a>标记其父级的大小< li>标记用于较大的可点击区域? [英] How do I make an <a> tag the size of it's parent <li> tag for larger clickable region?

查看:85
本文介绍了如何制作< a>标记其父级的大小< li>标记用于较大的可点击区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这样做,以便标记上的可点击区域是 LI 的大小。

I would like to do this so that the clickable region on the tag is size of the LI.

我的html看起来像:

My html looks like:

<li>
 <a href="#">Link</a>
</li>


推荐答案

正如其他人所说

li a { display: block; }

,您还必须从< li>并将其设置在< a>代替。例如:

should achieve what you're after. But you must also remove any padding from the <li> and set it on the <a> instead. For example:

li { padding: 0; }
  li a { display: block; padding: 1em; }

这篇关于如何制作&lt; a&gt;标记其父级的大小&lt; li&gt;标记用于较大的可点击区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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