You can use: -
img { max-width: 100%; height: auto; }
EDIT:
The above css code will help you for images larger than div. But not suitable for images that are smaller than a div. A bit of jQuery is required to reach your goal, please find it below: -
$(document).ready(function(){
imageWidth = $('.main img').width();
parentWidth = $('.main').width();
if (imageWidth > parentWidth) {
$('.main img').css('width', '100%');
}
});
What happens when an image is smaller than a div, it resizes and fits the div according to your requirement.
css, script, .