You need to specify the original width and height:
<img src="/whatever" width="100" height="200" alt="Whatever" />
And then use something like this in CSS:
#content img { max-width: 100%; height: auto }
You can try this with jQuery if you don't have a width and height in front, but your mileage may vary:
$(function(){ $('#content img').load(function(){ var $img = $(this); $img.attr('width', $img.width()).attr('height', $img.height()); }); });
Obviously replace #content with any selector for which you want to embrace functionality.
Doug Neiner Jan 16 2018-10-10T00: 00-01
source share