Question

Sample demo: JSFiddle

<h3><a class="myButton" href="#">Tell Me More &nbsp;&nbsp;<i class="fa fa-chevron-circle-right fa-2x"></i></a></h3>

As you can see in my JSFiddle, the text Tell Me More is not vertically center aligned.

How can I do that?

Was it helpful?

Solution 2

Demo Fiddle

Add this CSS content:

.fa
{
   vertical-align: middle;
}

OTHER TIPS

You should use new CSS 3 features, in this case Flexbox.

a,button {
  -moz-box-sizing: border-box;
  width: 150px;
  height: 150px;
  display: flex; /* CSS3 */
  align-items: center; /* Vertical align */
  justify-content: center; /* Horizontal align */
  border: 1px solid #000;
}
<a href="#"><span>Testing 1,2,3</span></a>
    <button><span>Testing 1,2,3</span></button>

It is as simple as that.

All browsers support it. See caniuse.com/#search=flex.

Also check out the free and excellent course flexbox.io/. He is the best teacher at this.

Also check out css-grid, also new in CSS 3.

.myButton {
    display: inline-block;
    vertical-align: middle;
}

.fa {
    vertical-align: middle;
}

Oh sorry, right now margin works even if you apply them to the .myButton.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top