Struggling to vertically align elements within a div? Here's a snippet of code that might help:
Here's a sample of what you might have:
html
<div class="test">
<a href="#"><img src="test.png"/></a>
<a href="#">Text here...</a>
</div>
<div class="test">
<a href="#"><img src="test1.png"/></a>
<a href="#">Text here...</a>
</div>
<div class="test">
<a href="#"><img src="test2.png"/></a>
<a href="#">Text here...</a>
</div>
CSS:
.test {
display: inline-block;
height: 50px;
position: relative;
vertical-align: middle;
}
.test img {
vertical-align: middle;
}
Even if your images have varying heights, this code should help align everything vertically within the test div. Give it a try and let me know how it works for you!