Ideally, the div should have a width and height declared (value: let the content determine the dimensions)
$('div_selector_here').on('click',function(){
$(this).css('overflow','visible');
$(this).css('overflow','auto');
});
Alternatively, you can add this to make sure the image is wrapped in a div (and again, this is the idea that you are not setting the width and height for the div):
img{
display:block;
width:100%;
}
source
share