CSS:Clickable Li(文本缩进链接)

时间:2014-08-07 19:36:20

标签: css

我有关于具有背景图像的列表项的类。我想将文本缩进锚标记文本并使整个列表项可单击。我无法更改标记,并且具有背景的类需要应用于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;
}

1 个答案:

答案 0 :(得分:0)

试试这个

JSfiddle Demo

<强> 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 */
}