图像尺寸自动缩小 [英] image size reduced automatically

查看:98
本文介绍了图像尺寸自动缩小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在j查询中寻找代码,以减小图像大小以减小其在同一网站上不同位置的大小(例如,如果您看到facebook,则左上面板的个人资料图像很大,并且图像缩小了)大小,当此图像带有注释框出现时.).

I am looking for a code in j-query , regarding image size reducing its size at different place on the same website (e.g. if you see facebook, the profile image of individual at left top panel is big and same image is reduced in size when this image appears with comment box) .

推荐答案

您可以简单地执行
myImage.attr("width", newWidth);
//or
myImage.attr("height", newHeight);

,其中myImage是DOM与您img元素相对应的对象.如果在HTML和HTML中的JavaScript代码中仅更改了width或仅更改了height(或者更好的是,在HTML中均未定义widthheight),则将保留相同的纵横比;否则,将保持不变.它由图像的自然"尺寸定义.

—SA

where myImage is the DOM object corresponding to you img element. If you change only width or only height in both JavaScript code in and in HTML (or better yet, neither width nor height is defined in HTML), the same aspect ratio is preserved; it is defined by the "natural" dimensions of the image.

—SA


这篇关于图像尺寸自动缩小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆