I have a list of images which I need to align center both vertically and horizontally. How do I align the images in the center of the their respective li
both horizontally and vertically using jquery?
demo at codepen.io.
html:
<ul id="snap-list">
<li class="snap">
<img src="http://placehold.it/350x150">
</li>
<li class="snap">
<img src="http://placehold.it/250x350">
</li>
...
...
...
<li class="snap">
<img src="http://placehold.it/350x250">
</li>
<span class="clear_both"></span>
</ul>
css:
#snap-list {
list-style-type: none;
width: 100%;
}
#snap-list .snap {
width: 202px;
height: 202px;
float: left;
margin: 5px;
outline: 1px solid lightgray;
}
#snap-list .snap img {
max-width: 100%;
max-height: 100%;
}