I want to vertically middle align the icon and text for the Bootstrap <a>
tag button, my style snippet only works for <button>
tag but fails for <a>
tag.
In the below snippet:
- "User" button is using
<button>
to perform (my desire style!) - "Mail" button is using
<a>
tag to perform.
Please note that:
- Cannot modify the html code
- Cannot assign fixed margin to the icon or text, because there may have multi-line text inside the button
.btn-giant {
display: inline-block;
width: 120px;
height: 120px;
margin-bottom: 8px;
margin-right: 5px;
padding: 10px 15px;
font-size: 12px;
text-align: center;
color: white;
border-radius: 0;
white-space: normal;
}
.btn-giant .glyphicon {
font-size: 36px;
display: block;
margin-bottom: .3em;
}
<link href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.2.3.min.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/bootstrap.min.js"></script>
<button class="btn btn-giant btn-primary" onclick="location.href='/Users';">
<span class="glyphicon glyphicon-user" aria-hidden="true"></span> Users
</button>
<a class="btn btn-giant btn-primary" href="/Mail">
<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span> Mail
</a>