cursor:指针不起作用:在元素之后?

41 html css

我在Chrome中查看以下示例,似乎无法开始cursor: pointer使用该:after元素li.有办法解决这个问题吗?

http://jsfiddle.net/qKMPQ/2/

Wex*_*Wex 30

不是cursor: pointer:after元素上设置,而是将其设置在整个元素上,li它将显示在两者上.

编辑:
对于那些尝试在li:after伪元素上使用不同游标的人,您只需要明确定义cursor其中内容的属性li.看到这个更新的小提琴:http://jsfiddle.net/qKMPQ/20/

<ul>
    <li>
        <a href="#"></a>
    </li>
</ul>
Run Code Online (Sandbox Code Playgroud)
ul { list-style-type: none; }
li { cursor: pointer; }
a {
    background: red;
    float: left;
    width: 100px;
    height: 100px;
    cursor: help;
    display: block; }
li:after {
    content: "";
    background: yellow;
    float: left;
    width: 100px;
    height: 100px;
    display: block; }
Run Code Online (Sandbox Code Playgroud)

  • 但是如果我需要在li和它中使用不同的游标:在伪元素之后呢? (18认同)
  • @Wex知道如果我只在`<li>`中有文本怎么做,但是我仍然需要在我的`:after`伪元素上使用另一个游标? (5认同)
  • 在li元素上使用css ** pointer-events:none; **,在伪类:: after或:: before上使用pointer-events:auto; **。 (2认同)