How to write :hover condition for a:before and a:after?

后端 未结 7 1612
北恋
北恋 2020-11-22 13:08

How to write :hover and :visited condition for a:before?

I\'m trying a:before:hover but it\'s not working

7条回答
  •  长情又很酷
    2020-11-22 13:22

    BoltClock's answer is correct. The only thing I want to append is that if you want to only select the pseudo element, put in a span.

    For example:

  • List Element
  • instead of:

  • data-icon='u' List Element
  • This way you can simply say

    ul [data-icon]:hover::before {color: #f7f7f7;}
    

    which will only highlight the pseudo element, not the entire li element

提交回复
热议问题