HTML
<div>
<div style="overflow: auto">
<img class="preview_img" src="/myImg" />
<img class="preview_img" src="/myImg2" />
</div>
</div>
JS
btnZoomIn.click(function () {
previewImg.each(function () {
var width = $(this).width();
var height = $(this).height();
var newWidth = width * 1.2;
var newHeight = height * 1.2;
$(this).css('width', newWidth);
$(this).css('height', newHeight);
// $(this).width(newWidth);
// $(this).height(newHeight);
});
});
我想在按钮点击时调整img的大小,宽度将在600px上停止,
但高度可以无限制 .
我没有设置任何max-width属性(属性)
1 回答
也许从其他元素继承
max-width
,所以添加内联样式以防止max-width
规则:然后,如果存在问题,请检查父母的
max-width
或width
.