7

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?

James Donnelly
  • 126,410
  • 34
  • 208
  • 218
bashleigh
  • 8,813
  • 5
  • 29
  • 49

3 Answers3

6

You can combine the two:

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

JSFiddle.

James Donnelly
  • 126,410
  • 34
  • 208
  • 218
  • 1
    Ack, what a [cruel world](http://i.imgur.com/RUXL5vI.png) we live in on our ever lasting quest for the sacred upvotes! ;-) – James Donnelly Mar 21 '13 at 16:17
5

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

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

http://jsfiddle.net/uz3w4/

Darren
  • 68,902
  • 24
  • 138
  • 144
4

Yes of course you can :

Demo

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

a:hover:after {
    content: 'blah';
}
Mr. Alien
  • 153,751
  • 34
  • 298
  • 278