[英]How to make whole list item clickable
I was wondering how I could make the whole list item clickable and not just the words. 我想知道如何使整个列表项可单击,而不仅仅是单词。 In my list I am only able to click on the words. 在我的列表中,我只能单击单词。 How could I turn the whole list area into a link? 如何将整个列表区域变成链接? I have the list made with a link inside of it but I want you to be able to click anywhere inside the list area to get redirected. 我的列表中包含链接,但我希望您能够单击列表区域内的任何位置以进行重定向。 Thank you. 谢谢。
And I am new to this website so I am sorry if I am asking this wrong. 而且我是这个网站的新手,所以很抱歉如果我问错了。
You need to make the anchor tag a block element and let it control the height of the list item 您需要将锚标签设为一个块元素,并使其控制列表项的高度
here is a sample: 这是一个示例:
HTML: HTML:
<ul>
<li>
<a href="#">click me!</a>
</li>
</ul>
CSS: CSS:
ul {
width:200px;
padding:0px;
margin:0px;
list-style:none;
}
li {
width:100%;
background:green;
position: relative;
}
li a {
display:block;
height:50px;
}
jsfiddle: http://jsfiddle.net/24ELw/ jsfiddle: http : //jsfiddle.net/24ELw/
您可以只buttons inside the list items
插入buttons inside the list items
其设置为无边界且没有背景色的样式-> jsFiddle
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.