Skip to content

Anchor link by hovering the whole heading #18

Answered by allejo
xplosionmind asked this question in Q&A
Discussion options

You must be logged in to vote

Sure, just attach your :hover rule to the heading and give the anchors inside an opacity of 1.

<h1>My Heading <a href="#">#</a></h1>

Sass

// styles.scss
h1, h2, h3,
h4, h5, h6 {
  &:hover {
    a {
      opacity: 1;
    }
  }

  a {
    opacity: 0;
  }
}

CSS

// styles.css
h1:hover a, h2:hover a, h3:hover a,
h4:hover a, h5:hover a, h6:hover a {
  opacity: 1;
}
h1 a, h2 a, h3 a,
h4 a, h5 a, h6 a {
  opacity: 0;
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by allejo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #18 on December 19, 2020 23:33.