0

I want to make a link with a picture symbolizing play next to the text. What is the best way to do this? I wrote this code, but I don't think it's perfectly centered vertically. How can I center it perfectly?

a:after {
  content: '';
  display: inline-block;
  vertical-align: middle;
  width: 20px;
  height: 20px;
  background: url(https://img.icons8.com/material-sharp/24/000000/circled-play.png) center / cover no-repeat;
  margin-left: 5px;
}
<a href="#">Watch video</a>
Ori Drori
  • 145,770
  • 24
  • 170
  • 162

1 Answers1

1

You can use flexbox like, this will place your picture vertically center. Check out the solution below:

a {
  display :flex;
  align-items:center;
}
a:after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  background: url(https://img.icons8.com/material-sharp/24/000000/circled-play.png) center / cover no-repeat;
  margin-left: 5px;
}
<a href="#">Watch video</a>