我在具有背景图像的列表项上有类。我想文本缩进 anchor 标记文本并使整个列表项可点击。我无法更改标记,具有背景的类需要应用于 li 而不是 a。谢谢!
<ul>
<li> <a href="#">Link One </a></li>
<li> <a href="#">Link Two </a></li>
</ul>
ul {
list-style:none;
}
li {
display: inline-block;
text-indent: -999px;
background-color: lime;
width: 100px;
height: 100px;
margin-right: 10px;
}
li a {
text-indent: -9900px;
height: 100px;
width: 100px;
}
最佳答案
试试这个
CSS
ul {
list-style:none;
}
li {
display: inline-block;
background-color: lime;
margin-right: 10px;
}
li a {
text-indent: -9900px;
height: 100px; /* let the size of the link determine the li size */
width: 100px;
display: block; /* this is the vital part */
}
关于CSS:可点击的 Li(文本缩进链接),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25190780/