Skip to content

Instantly share code, notes, and snippets.

@ryanmorr
Last active January 16, 2024 21:01
Show Gist options
  • Save ryanmorr/5a99dc63421504b0c357023553eebe81 to your computer and use it in GitHub Desktop.
Save ryanmorr/5a99dc63421504b0c357023553eebe81 to your computer and use it in GitHub Desktop.
Allow an SVG icon to seamlessly blend with text
/* Courtesy of: https://www.24a11y.com/2018/accessible-svg-icons-with-inline-sprites/ */
.svg-icon {
/* Place the icon on the text baseline. */
position: relative;
top: .125em;
/* Prevent the icon from shrinking inside a flex container. */
flex-shrink: 0;
/* Scale the icon to match the font-size. */
height: 1em;
width: 1em;
/* Let the icon take whatever color the parent has. */
fill: currentColor;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment