Harry L Respass
Harry L Respass

Reputation: 27

Pseudo Element Before / After

I'm using an image to the left of a link.
Right now, I use the ::before attribute for the image to show, however it shows slightly above the link.

I need to have it aligned. Here's a pic: Link

The code I'm using is:

 .vocabulary-duration::before {
     content: "";
     float: left;
     font-family: "FontAwesome";
     font-size: 18px;
     padding-right: 0.5em;
 }

Upvotes: 0

Views: 55

Answers (1)

Michael Coker
Michael Coker

Reputation: 53664

You can remove the float and use inline or inline-block and then use vertical-align

.vocabulary-duration::before {
  content: "";
  font-family: "FontAwesome";
  font-size: 18px;
  padding-right: 0.5em;
  vertical-align: middle;
  display: inline-block;
}
<div class="vocabulary-duration">asdf</div>

Upvotes: 1

Related Questions