Why ::before pseudo-element not working with :visited pseudo-class?

后端 未结 4 1987
再見小時候
再見小時候 2021-02-02 11:11

I\'m trying to style my element with pseudo-class and pseudo-element. like hover::before is working perfectly but :visited::before is not working.

4条回答
  •  北荒
    北荒 (楼主)
    2021-02-02 11:50

    It may be possible, but don't take it for granted. According to the spec,

    Note: It is possible for style sheet authors to abuse the :link and :visited pseudo-classes to determine which sites a user has visited without the user's consent.

    UAs may therefore treat all links as unvisited links, or implement other measures to preserve the user's privacy while rendering visited and unvisited links differently.

    Inserting content can change the size of the element, so it would be trivial to detect this and know if the user has visited some sites. Therefore, most browsers won't allow you to do so.

提交回复
热议问题