Skip to content

Instantly share code, notes, and snippets.

@6ui11em
Last active October 21, 2020 08:13
Show Gist options
  • Save 6ui11em/6631c770540e37862c8722ac9bd806ba to your computer and use it in GitHub Desktop.
Save 6ui11em/6631c770540e37862c8722ac9bd806ba to your computer and use it in GitHub Desktop.
CSS: Bold on Hover without layout shift #css #scss #bold #hover
/*
By Ryan Mulligan
Source: https://css-tricks.com/bold-on-hover-without-the-layout-shift/
*/
.menu-link {
display: inline-flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 1rem 1.5rem;
color: black;
text-decoration: none;
&:hover {
font-weight: var(--bold);
}
}
.menu.fix .menu-link::after {
content: attr(data-text);
content: attr(data-text) / "";
height: 0;
visibility: hidden;
overflow: hidden;
user-select: none;
pointer-events: none;
font-weight: var(--bold);
@media speech {
display: none;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment