As you can see in your example, the images are positioned at the center (starting from the top left corner).
To make the center the way you desire, I suggest this solution:
How to make an image center (vertically & horizontally) inside a bigger div
Since you're already using jQuery to manipulate the image's size, add their margin-top
and margin-left
programmatically (half for each).
EDIT:
(I don't know how you're placing the image size, you may need to change the height()
and width()
by $("#co-logo img").css('height')
and $("#co-logo img").css('width')
)
The javascript with jQuery to add the inline styles:
simplified:
$("#co-logo img").css({'margin-top': -($("#co-logo img").height() / 2) + "px", 'margin-left': -($("#co-logo img").width() / 2) + "px"});
explained:
//get the image size:
var theHeight = $("#co-logo img").height();
var theWidth = $("#co-logo img").width();
//place them into the image styles:
$("#co-logo img").css({'margin-top': -theHeight / 2 + "px", 'margin-left': -theWidth / 2 + "px"});
EDIT 2:
Using each
to loop between every image.
Assuming you had the same ID for each block, you need to swap it with a class, like .co-logo
instead of #co-logo
(because IDs are unique), call the each like this:
$(".co-logo").each(function(){
$("img", $(this)).css({'margin-top': -($("img", $(this)).height() / 2) + "px", 'margin-left': -($("img", $(this)).width() / 2) + "px"});
});
That will do the trick!