imgCentering.js
A lightweight jQuery plugin to centering your Images

$('.imgset1 img').imgCentering();	//centering only no stretch
$('.imgset2 img').imgCentering({
	'forceWidth': true,		//centering with fix width
	'bgColor': '#000'		//empty space color
});
$('.imgset3 img').imgCentering({
	'forceHeight': true,		//centering with fix height
	'bgColor': '#000'		//empty space color
});
$('.imgset4 img').imgCentering({
	'forceSmart': true		//centering without showing background
});

来源:有图素材网

转载请注明出处,此代码仅供学习交流,请勿用于商业用途。