img查看大图时图片变形

layui.use('layer', function () {
var layer = layui.layer;
var img = new Image();
img.src = imgUrl;
var content = '<div style="text-align:center;overflow: hidden;' + img.width + 'px;height:' + img.height+ 'px"><img style="max-100%;max-height:100%;left:0;top:0;right:0;bottom:0;margin:auto" src="' + imgUrl + '"/></div>';

layer.open({
title: false,
type: 1,
offset: 'auto',
btn: false,
closeBtn: false,
area: [w + 'px', h + 'px'],
content: content,
success: function (e, i) {
e.dblclick(function () {
layer.close(i);
});
}
});
});

原文地址:https://www.cnblogs.com/yyjspace/p/11607682.html