button, a {
height: 30px;
display: inline-block;
border: 1px solid black;
vertical-align: middle;
}
button > div, a > div {
width: 30px;
height: 10px;
background-color: red;
}
<button>
<div class="buttonDiv"></div>
</button>
<a href="#">
<div class="anchorDiv"></div>
</a>
We are currently facing an issue in our project regarding the alignment of buttons with icons that render as either a button or an anchor based on props. The misalignment of button content has become a challenge for us, as demonstrated in the code snippet provided.
Why is the inner div
aligning differently in a button compared to an anchor? How can I correctly align the contents of the button vertically without simply adding padding-top?