Skip to content

Instantly share code, notes, and snippets.

@davdenic
Last active December 17, 2022 16:50
Show Gist options
  • Save davdenic/35bf7f132976a3e2d13217689e137c15 to your computer and use it in GitHub Desktop.
Save davdenic/35bf7f132976a3e2d13217689e137c15 to your computer and use it in GitHub Desktop.
CSS hover apply to parent elements
.parent {
    background: white;
    pointer-events: none; // this disable the hover on the .parent

    &:hover {
      background: gray; // hover applied to .parent but disabled by the previous pointer-events: none;
    }
    a {
      pointer-events: auto; // this enable the pointer again
      &:hover {
        color: red; // this hover only for the a 
      }
    }
}
<span class="parent">
  text
  <a href="/link.html">x</a>
</span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment