Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
465 views
in Technique[技术] by (71.8m points)

html - cursor: pointer doesn't work on :after element?

I'm viewing the below example in Chrome and can't seem to get cursor: pointer to work on the :after element of li. Is there a way to get around this?

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Instead of setting the cursor: pointer on the :after element, set it on the entire li and it will show up on both.

Edit:
For those of you trying to have different cursors on the li and its :after pseudo-element, you simply need to explicitly define the cursor property of the content inside the li. See this updated fiddle: http://jsfiddle.net/qKMPQ/20/

<ul>
    <li>
        <a href="#"></a>
    </li>
</ul>
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; }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...