http://stackoverflow.com/questions/11757537/css-image-size-how-to-fill-not-stretch

.container { width: 150px; height: 100px; background-image: url(“http://i.stack.imgur.com/2OrtT.jpg"); background-size: cover; background-repeat: no-repeat; background-position: 50% 50%; }​ http://stackoverflow.com/questions/9883289/set-background-image-css-to-the-featured-image-in-wordpress-using-jquery 這個做了我想做的事,也是高手 $(‘section img’).each( function(){ var src = this.src, h = $(this).height(), w = $(this).width(); $(this).closest(‘div’).css({ ‘min-width’ : w, ‘min-height’ : h, ‘background-image’ : ‘url(’ + src + ‘)’, ‘background-repeat’ : ‘no-repeat’, ‘background-position’ : ‘50% 50%’ }); }).remove();

======= ‘background-image’ : ‘url(’ + src + ‘)’, 記得在加上”" => ‘background-image’ : ‘url("’ + src + ‘")’,