The problem is that you get the distortion by reducing the width of the image. Try to wrap the image in the div:
<div id="main">
<div id="img1">
<img src="..."/>
</div>
<div id="img2">
<img src="..."/>
</div>
</div>
$("#img2").animate({ width: 'toggle', height:'340', opacity: 'toggle' }, "slow");
Simple example: https://jsfiddle.net/12x4cauv/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.