Struggling to center product images vertically within a fixed height box? Here's the code I've been working with:
<div class="main-pic">
<ul>
<li><img src="images/extra/laptop.jpg"></li>
<li><img src="images/extra/laptop1.jpg"></li>
<li><img src="images/extra/laptop2.jpg"></li>
<li><img src="images/extra/laptop3.jpg"></li>
<li><img src="images/extra/laptop4.jpg"></li>
<li><img src="images/extra/laptop5.jpg"></li>
</ul>
</div>
And here is the CSS I've been using:
.main-pic{width:430px;height:430px;border:1px solid black;margin:20px auto;display:block;float:none;overflow:hidden;}
.main-pic ul{width:10000px;}
.main-pic ul li{width:430px;height:430px;float:none;display:block;margin:-25% auto auto;position:relative;top:50%;}
.main-pic ul li img{max-width: 400px;height:auto;max-height: 400px;width: auto;}
I've tried vertical-align:middle;
and display:table-cell;
but haven't had any luck. Any suggestions to help me achieve the desired result would be greatly appreciated!