Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get dashicon to align vertically with text

I am using the dashicons which are built into wordpress.

Whenever I am using an icon in front or after a text, they are out of alignment. How would I make it, so that the icon aligns with the text?

I could change the HTML to make it a separate element, but preferentially looking for a css solution only, using the "before" selector.

a:link {
    text-decoration: none;
}

.fullscreen:before {
    font-family: "dashicons";
    content: "\f211 ";
    font-size:20px;
}

<a class="fullscreen" href="#">FULL SCREEN</a>

jsfiddle

like image 911
Kevin M Avatar asked Nov 05 '25 13:11

Kevin M


1 Answers

You can use inline-block and middle alignment on your icon :before. Example:

.fullscreen:before {
  font-family: "dashicons";
  content: "\f211 ";
  font-size:20px;
  display: inline-block;
  vertical-align: middle;
}

See Updated Fiddle

like image 111
Nanang Mahdaen El-Agung Avatar answered Nov 07 '25 03:11

Nanang Mahdaen El-Agung



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!