简体   繁体   English

css 异常行为:之前在 hover

[英]css unusual behaviour for :before on hover

I have a wordpress website with this free theme: https://wordpress.org/themes/minimal-grid/我有一个带有这个免费主题的 wordpress 网站: https://wordpress.org/themes/minimal-grid/

I'm seeing some unusual behaviour, which isn't a problem and I can fix by removing the element, but I don't know why it's happening and would like to understand it.我看到一些不寻常的行为,这不是问题,我可以通过删除元素来修复,但我不知道为什么会发生这种情况并想了解它。

At the end of each post, there is a link to the previous and next post.每篇文章的末尾都有上一篇和下一篇文章的链接。 When I hover over these, the background of the element darkens slightly.当我 hover 超过这些时,元素的背景会稍微变暗。 Where there is an image as background, it doesn't disappear, just darkens.在有图像作为背景的地方,它不会消失,只会变暗。 Here's a page that demonstrates: https://5diraptor.com/todoist-task-project-manager/这是一个演示页面: https://5diraptor.com/todoist-task-project-manager/

The unusual part is there doesn't seem to be any :hover selectors which actually tells it to do this, so I'd like to understand why it's happening.不寻常的部分是似乎没有任何:hover选择器实际上告诉它这样做,所以我想了解它为什么会发生。 Below is the HTML:下面是 HTML:

<nav class="navigation post-navigation" role="navigation" aria-label="Posts">
  <h2 class="screen-reader-text">Post navigation</h2>
  <div class="nav-links">

    <div class="nav-previous">
      <a href="https://5diraptor.com/vivaldi-browser/" rel="prev">
        ::before
        <span class="meta-nav" aria-hidden="true">Previous</span>
        <span class="screen-reader-text">Previous post:</span>
        <span class="post-title">Vivaldi Browser</span>
      </a>
    </div>

    <div class="nav-next">
      <a href="https://5diraptor.com/wordpress-development/" rel="next">
        ::before
        <span class="meta-nav" aria-hidden="true">Next</span>
        <span class="screen-reader-text">Next post:</span>
        <span class="post-title">WordPress Development</span>
      </a>
    </div>

  </div>
</nav>

There's no:hover selectors on any of these elements which change background color.在这些改变背景颜色的任何元素上都没有:hover 选择器。 However, when I remove the ::before elements in Chrome Dev tools, the hover transition no longer happens.但是,当我在 Chrome 开发工具中删除::before元素时,hover 转换不再发生。

What I don't understand is there's no :hover selector on the ::before pseudo-element, and there's no color related CSS applied to this - see screenshot.我不明白的是::before伪元素上没有:hover选择器,并且没有与颜色相关的 CSS 应用于此 - 参见屏幕截图。 There's also no event listeners for mouseover so I'm pretty sure this isn't Javascript. mouseover也没有事件监听器,所以我很确定这不是 Javascript。

在此处输入图像描述

I can't force element state to hover for pseudo-elements so I'm not sure how to debug this any further.对于伪元素,我无法将元素 state 强制为 hover,所以我不确定如何进一步调试它。 Can anyone help me understand why this is happening?谁能帮我理解为什么会这样?

See it has a style for the hover state of the parent nav-previous and the rule applies to the pseudo element when it is hovered.看到它具有父nav-previous的 hover state 的样式,并且该规则在悬停时适用于伪元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM