Sample demo: JSFiddle
<h3><a class="myButton" href="#">Tell Me More <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?
Sample demo: JSFiddle
<h3><a class="myButton" href="#">Tell Me More <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?
MARGIN-TOP
on myButton
class selector. What i mean is MARGIN-TOP don't work. –
Jenniejennifer 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.
MARGIN-TOP
on myButton
class selector. What i mean is MARGIN-TOP don't work. –
Jenniejennifer .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
.
© 2022 - 2024 — McMap. All rights reserved.