I find it best to go with a bit of JavaScript that converts the image from the <img> to a background image:
<div class="wide-image"><img src="..."></div>
JavaScript using jQuery (but you can easily do it without it / using another tool):
ββ$(function() { $('.wide-image').each(function() { var $div = $(this), $img = $div.find('img:first'); // Transform normal image into background image $div.css('background', 'url(' + $img.attr('src') + ') no-repeat center center'); // Adjust the <div>s height to fit the image height $div.height($img.height()); // Hide the original image $img.hide(); }); });β
Demo: http://jsfiddle.net/NBKsm/
source share