Each image has a div parent, these parents' width and height are in proportion, the question is, i can't center each image inside its parent horizontally. it seems it only takes the first element's height and applies it to the rest of the elements. ![it seems it only takes the first elements height and apply it to all of the rest ][1]
function centerImages(image) {
var parent_height = $('.thumb img').parent().height();
var image_height = $('.thumb img').height();
var top_margin = (parent_height - image_height) / 2;
$('.thumb img').css( 'margin-top' , top_margin);
}
$(".thumb img").each(function() {
centerImages(this);
});