So I'm making a button with an icon on the left. And the alignment is messed up. My text doesn't middle align with the icon and I have no idea how to fix this. Line-height doesn't seem to do anything. Or touching the padding/margins because I've added the padding to the icon area because I need it to be darker than the text background.
Here's the image preview:
Is there a way I can fix the alignment? Or is there a way to do this type of a button easier with Bootstrap 4?
Here's my code:
.btn-primary {
background-color: #3382c7;
font-size: 10px;
font-weight: bold;
text-transform: uppercase;
span {
padding-left: 25px;
padding-right: 25px;
}
i {
font-size: 20px;
background-color: #306fa5;
padding: 15px 20px;
}
}
<a href="#" class="btn btn-primary border-0 rounded-0 p-0">
<i class="fa fa-play" aria-hidden="true"></i>
<span>Click here to Play</span>
</a>
Use align-middle
class on the span and icon..
<div class="container">
<a href="#" class="btn btn-primary border-0 rounded-0 p-0">
<i class="fa fa-play align-middle" aria-hidden="true"></i>
<span class="align-middle">Click here to Play</span>
</a>
</div>
http://www.codeply.com/go/xuiy1703Dv
If you make them display: inline-block
and vertical-align: middle
it should work for you
.btn-primary {
background-color: #3382c7;
display: inline-block;
font-size: 10px;
font-weight: bold;
text-transform: uppercase;
}
.btn-primary span {
display: inline-block;
padding-left: 25px;
padding-right: 25px;
vertical-align: middle;
}
.btn-primary i {
font-size: 20px;
display: inline-block;
background-color: #306fa5;
padding: 15px 20px;
vertical-align: middle;
}
<a href="#" class="btn btn-primary border-0 rounded-0 p-0">
<i class="fa fa-play" aria-hidden="true"></i>
<span>Click here to Play</span>
</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With