using both :after and :hover
Asked Answered
S

3

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?

Supplicatory answered 21/3, 2013 at 16:4 Comment(6)
Have you tried #parent:hover:after?Window
Did you try it?Dozer
@Window I have but I left a space like this #parent:hover :after is that my problem? lolSupplicatory
Yes, remove the space and that should helpWindow
@Window Yea that sorted it face palmSupplicatory
@Beneto #parent:hover :after would style the #parent's child element's :after, rather than styling the actual #parent's :after.Bartender
B
6

You can combine the two:

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

JSFiddle.

Bartender answered 21/3, 2013 at 16:5 Comment(1)
Ack, what a cruel world we live in on our ever lasting quest for the sacred upvotes! ;-)Bartender
O
5

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

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

http://jsfiddle.net/uz3w4/

Optics answered 21/3, 2013 at 16:6 Comment(0)
S
4

Yes of course you can :

Demo

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

a:hover:after {
    content: 'blah';
}
Starlin answered 21/3, 2013 at 16:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.