bashleigh
bashleigh

Reputation: 9314

using both :after and :hover

Is it possible to only display the :after pseudo using :hover? For example using alternative elements.

#parent{}
#child{display:none;}
#parent:hover >#child{display:block;}

As far as I've got with the same method:

#parent{}
#parent:after{content:'hi';display:none;}
#parent:hover  #parent:after{display:block;}

Is it possible at all? Or am I fooling myself?

Upvotes: 7

Views: 219

Answers (3)

James Donnelly
James Donnelly

Reputation: 128791

You can combine the two:

#parent:hover:after {
    content:'hi';
}

JSFiddle.

Upvotes: 6

Darren
Darren

Reputation: 70728

Yes. Not sure why you didn't try it yourself but it's possible:

#parent:hover:after{content:'hi';}

http://jsfiddle.net/uz3w4/

Upvotes: 5

Mr. Alien
Mr. Alien

Reputation: 157334

Yes of course you can :

Demo

<a href="#">Demo</a>

a:hover:after {
    content: 'blah';
}

Upvotes: 4

Related Questions