How do I set the position of an image to be in the center of a div (both vertically and horizontally). I can make it horizontally center, but how to center it vertically?
N.B: height and width of the images may change.
html:
{% for photo in photos %}
<div class="thumbnail_container">
<a class='gallery' href='{{MEDIA_URL}}{{photo.image}}'><img src="{{MEDIA_URL}}{{photo.image}}" class="thumbnail"></a>
</div>
{% endfor %}
<span class="clear_left"></span>
css:
.thumbnail_container {
background-color: white;
border: 1px solid red;
width: 250px;
height: 200px;
float: left;
margin: 5px;
}
.thumbnail {
display: block;
margin-left: auto;
margin-right: auto;
border: 1px solid red;
max-width: 240px;
max-height: 190px;
}
Any help will be much appreciated! Thanks.